← Back to team overview

kicad-developers team mailing list archive

Re: Patch: move newstroke definitions to separate .cpp

 

Manveru wrote:
[Attachment(s) <#TopText> from Manveru included below]

Hi,

This patch is not ideal, as the the size of the array has to be declared in newstroke_font.h, because sizeof() operator is used in drawtxt.cpp.

I have an idea how to modify the code to feed hashmap from array of glyphs we already have defined, ignoring all "F^K[KFYFY[K[", which may reduce amount of memory used to store glyphs in code (I am even thinking about compression, as text format used is very compressible), and make the code more objective in approach.

1) Check your copyright message. It is my understanding that this work belongs to Vladimir, not Jean-Pierre. Correct me if I am wrong Jean-Pierre or Vladimir.

2) You can extern the size of the array by declaring an unsigned to hold it.

---------*.h-------------

extern unsigned newstroke_fontz;


----------*.cpp-----------

newstroke_font = {....};

// then just below:

unsigned newstroke_fontz = DIM( newstroke_font );

-------------------------------


3) Hashmap is a good idea. I don't think the compression is. Hashmap can come from the C++ compiler, but only after about version gcc 4.2. So therefore I suggest using the one from boost, and this means adding a few more header files, and not relying on Hashmap being in the stdc++ library. (I've been through this recently.) We may need hashmap again somewhere else, it should be in the boost headers that we use. Somebody please add it. The stdc++ hashmap in newer compilers came from boost anyway.


I would go ahead and add the hashmap support, and then if the lookup fails due to a hole in the character space, return this silly string you talk about. You will probably have to wrap the thing in a dummy C++ class so that its constructor can build the hashmap at program load time, using a static constructor invoked on a global instance.


Dick









Follow ups

References