← Back to team overview

kicad-developers team mailing list archive

Re: Patch: move newstroke definitions to separate .cpp

 

Dick Hollenbeck wrote:
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.

Sorry, I mis-spoke. I was thinking of:

boost::unordered_map

which in my view is the best container to hold this sparse array.

To truly save memory, I'm wondering if we don't have to read the font file line by line from disk, and then create the

unordered_map (which is a hashtable)

The best input data form for the hashtable stuffing process would be a 2 column tuple of character integer value and string.

There is no way to get the compiler to build the the hashtable at compile time. Maybe simply reading the font file from disk is best, using a two column CSV file.

A font file could simply be a CSV file consisting of the character's integer value and the string. Or you can keep this in RAM, by the RAM array needs to be a two column tuple, then when stuffing the hashtable, simply put a pointer to the string, not a copy of the string, otherwise you'd be paying for the string memory twice.


Dick









References