Which font was used in the program?
This is not a fixed-width font, and I wanted to make a small pcb file viewer. I want it to read kicad_pcb files and stop on fonts.
Afaik it’s a custom font inside KiCAD, that’s made from polylines.
It’s a custom font that consists of bunch of segments. I have solved very similar problem to one you are facing now in my plugin:
That issue has links to both font description, it’s rendering code in KiCad and a commit that replicates this logic in python+javascript.
If you have any question I can probably help. What language are you writing your viewer in and what rendering libs are you using?
What is the data format in the file newstroke_font.h?
This is the main font file or do you still need to use others?
I’m doing a small browser, which will show you where is the element. There is no editing. I do it straight in php-> html-> javascript->canvas. I already have zones, paths, dimensions, drawings, via and many more, but the text remained mostly me.
Take a look at this function which converts a character into a list of polylines.
The format is some one-off compact encoding. Each character is described by a string where first two chars are dimensions and the remaining ones describe segments. Coordinates are offset by ‘R’ and there is special code for line break: space + ‘R’.
And yes, you only need newstroke_font.h
The KiCad font is derived from an old font data called Hershey fonts. It’s been tweaked and extended but is basically similar.
Ok, that’s it. Thanks.
The characters are and the interpretation of the * .h file works. Now only display: mirror, left, right, center, italic :).
If I have questions, I will write.
Parsing text attributes is here
Rendering text on canvas here
Note that before calling drawtext() I already transformed and rotated the canvas to relative position, angle and scale needed.
Thank you very much.
I advised myself with parsing “by my method”. I used “interline” from your code because I have already written the others.
Until the end I still have to do only fp_text, fp_circle, fp_arc and pad.
The code is maybe not as nice as yours, but it has to work :). There is no time for such a good aesthetics.
When I’m done I’ll put a screenshot.
Looks good. Any plans to open source your project?
No. This is a badly written code :). There is no time for any exact plan of this code. Works very well, but I am ashamed to brag :).
I have a small company with little serial production and manual assembly. This is part of the system that facilitates assembly, search of elements, synchronization with the magazine.
This is just a small part that depends on many others.
Three more screenshots. 1 - the original comes from kicad, 2 - my program, 3 - an example of a screenshot from the warehouse base
This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.