18 changed files with 23050 additions and 12 deletions
-
9686common/gal/opengl/bitmap_font_desc.c
-
1034common/gal/opengl/bitmap_font_img.c
-
177common/gal/opengl/opengl_gal.cpp
-
13common/gal/opengl/shader.frag
-
3common/gal/opengl/shader.vert
-
42helpers/gal_bitmap_font/README
-
1133helpers/gal_bitmap_font/bitmap_font.fnt
-
BINhelpers/gal_bitmap_font/bitmap_font_0.png
-
1034helpers/gal_bitmap_font/bitmap_font_0_img.c
-
9686helpers/gal_bitmap_font/bitmap_font_desc.c
-
88helpers/gal_bitmap_font/fnt2struct.py
-
59helpers/gal_bitmap_font/font.bmc
-
70helpers/gal_bitmap_font/png2struct.py
-
15include/gal/graphics_abstraction_layer.h
-
8include/gal/opengl/opengl_gal.h
-
1include/gal/opengl/vertex_common.h
-
6pcbnew/pcb_draw_panel_gal.cpp
-
7pcbnew/pcb_painter.cpp
9686
common/gal/opengl/bitmap_font_desc.c
File diff suppressed because it is too large
View File
File diff suppressed because it is too large
View File
1034
common/gal/opengl/bitmap_font_img.c
File diff suppressed because it is too large
View File
File diff suppressed because it is too large
View File
@ -0,0 +1,42 @@ |
|||
Creating bitmap fonts for GAL |
|||
============================= |
|||
Maciej Suminski <maciej.suminski@cern.ch> |
|||
12.04.2016 |
|||
|
|||
To create a new bitmap font atlas for Graphics Abstraction Layer, follow these steps: |
|||
|
|||
* Download Bitmap Font Generator [1] (runs well under wine) |
|||
* Load default configuration stored in font.bmfc |
|||
* Adjust settings as needed |
|||
* Be sure that all glyphs fit into one page (you can check if in 'Visualize' you can move to another page (menu View)) |
|||
* Export font atlas as .PNG file, and font description as XML file |
|||
* Run ./fnt2struct.py bitmap_font.fnt |
|||
* Run ./png2struct.py bitmap_font_0.png |
|||
* Copy bitmap_font_desc.c to common/gal/opengl/bitmap_font_desc.c |
|||
* Copy bitmap_font_0.png to common/gal/opengl/bitmap_font_img.c |
|||
|
|||
Recommended export options: |
|||
Texture size: 1024x1024 (should be supported by majority GPUs) |
|||
Bit depth: 8 |
|||
Font descriptor: XML |
|||
Textures: png |
|||
|
|||
To match as closely as possible the newstroke_font glyph set, |
|||
mark the following character subsets in Bitmap Font Generator right panel: |
|||
Latin + Latin Supplement |
|||
Latin Extended A |
|||
Latin Extended B |
|||
IPA Extensions |
|||
Greek and Coptic |
|||
Cyrillic |
|||
Latin Extended Additional |
|||
Greek Extended |
|||
General Punctuation |
|||
Subscripts and Superscripts |
|||
Currency Symbols |
|||
Number Forms |
|||
Mathematical Operators |
|||
Geometric Shapes |
|||
|
|||
References: |
|||
1. http://www.angelcode.com/products/bmfont/ |
|||
1133
helpers/gal_bitmap_font/bitmap_font.fnt
File diff suppressed because it is too large
View File
File diff suppressed because it is too large
View File
|
After Width: 1024 | Height: 1024 | Size: 235 KiB |
1034
helpers/gal_bitmap_font/bitmap_font_0_img.c
File diff suppressed because it is too large
View File
File diff suppressed because it is too large
View File
9686
helpers/gal_bitmap_font/bitmap_font_desc.c
File diff suppressed because it is too large
View File
File diff suppressed because it is too large
View File
@ -0,0 +1,88 @@ |
|||
#!/usr/bin/env python |
|||
|
|||
# This program source code file is part of KiCad, a free EDA CAD application. |
|||
# |
|||
# Copyright (C) 2016 CERN |
|||
# @author Maciej Suminski <maciej.suminski@cern.ch> |
|||
# |
|||
# This program is free software; you can redistribute it and/or |
|||
# modify it under the terms of the GNU General Public License |
|||
# as published by the Free Software Foundation; either version 2 |
|||
# of the License, or (at your option) any later version. |
|||
# |
|||
# This program is distributed in the hope that it will be useful, |
|||
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
# GNU General Public License for more details. |
|||
# |
|||
# You should have received a copy of the GNU General Public License |
|||
# along with this program; if not, you may find one here: |
|||
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html |
|||
# or you may search the http://www.gnu.org website for the version 2 license, |
|||
# or you may write to the Free Software Foundation, Inc., |
|||
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA |
|||
|
|||
# Converts a bitmap font atlas description in XML format to data stored |
|||
# in a C structure. |
|||
|
|||
import xml.etree.cElementTree as ET |
|||
import sys |
|||
import os |
|||
|
|||
def convert(xml_file): |
|||
tree = ET.ElementTree(file=xml_file) |
|||
root = tree.getroot() |
|||
|
|||
output = open(os.path.splitext(xml_file)[0] + '_desc.c', 'w') |
|||
|
|||
# Header |
|||
output.write( |
|||
""" |
|||
/* generated with fnt2struct.py, do not modify by hand */ |
|||
|
|||
static const struct bitmap_glyph { |
|||
unsigned int x, y; |
|||
unsigned int width, height; |
|||
int x_off, y_off; |
|||
} bitmap_chars[] = { |
|||
"""); |
|||
|
|||
last_id = 0 |
|||
fallback_line = '{ 0, 0, 0, 0, 0, 0 },\t\t/* %d (not defined) */\n' |
|||
|
|||
for char in root.iter('char'): |
|||
cur_id = int(char.attrib['id']) |
|||
# Fill gaps for the missing characters |
|||
while(cur_id > last_id): |
|||
output.write(fallback_line % last_id) |
|||
last_id = last_id + 1 |
|||
|
|||
output.write('{ %d, %d, %d, %d, %d, %d },\t/* %d */\n' % |
|||
(int(char.attrib['x']), int(char.attrib['y']), |
|||
int(char.attrib['width']), int(char.attrib['height']), |
|||
int(char.attrib['xoffset']), int(char.attrib['yoffset']), |
|||
cur_id)) |
|||
last_id = cur_id + 1 |
|||
|
|||
output.write('};\n') |
|||
|
|||
output.write('static const int bitmap_chars_count = %d;\n' % last_id) |
|||
|
|||
try: |
|||
lineHeight = int(root.find('common').get('lineHeight')) |
|||
except: |
|||
print('Could not determine the font height') |
|||
lineHeight = -1 |
|||
|
|||
output.write('static const int bitmap_chars_height = %d;\n' % (lineHeight)) |
|||
|
|||
output.close() |
|||
|
|||
#---------------------------------------------------------------------- |
|||
if __name__ == "__main__": |
|||
argc = len(sys.argv) |
|||
|
|||
if(argc == 2): |
|||
convert(sys.argv[1]) |
|||
else: |
|||
print("usage: %s <xml-file>" % sys.argv[0]) |
|||
@ -0,0 +1,59 @@ |
|||
# AngelCode Bitmap Font Generator configuration file |
|||
fileVersion=1 |
|||
|
|||
# font settings |
|||
fontName=Ubuntu Mono |
|||
fontFile= |
|||
charSet=0 |
|||
fontSize=55 |
|||
aa=2 |
|||
scaleH=100 |
|||
useSmoothing=1 |
|||
isBold=0 |
|||
isItalic=0 |
|||
useUnicode=1 |
|||
disableBoxChars=1 |
|||
outputInvalidCharGlyph=0 |
|||
dontIncludeKerningPairs=0 |
|||
useHinting=1 |
|||
renderFromOutline=1 |
|||
useClearType=1 |
|||
|
|||
# character alignment |
|||
paddingDown=0 |
|||
paddingUp=0 |
|||
paddingRight=0 |
|||
paddingLeft=0 |
|||
spacingHoriz=1 |
|||
spacingVert=1 |
|||
useFixedHeight=0 |
|||
forceZero=0 |
|||
|
|||
# output file |
|||
outWidth=1024 |
|||
outHeight=1024 |
|||
outBitDepth=8 |
|||
fontDescFormat=1 |
|||
fourChnlPacked=0 |
|||
textureFormat=png |
|||
textureCompression=0 |
|||
alphaChnl=1 |
|||
redChnl=0 |
|||
greenChnl=0 |
|||
blueChnl=0 |
|||
invA=0 |
|||
invR=0 |
|||
invG=0 |
|||
invB=0 |
|||
|
|||
# outline |
|||
outlineThickness=0 |
|||
|
|||
# selected chars |
|||
chars=0-0,8-9,13,29,32-126,160-591,658,900-902,904-906,908,910-929,931-974,1024-1119,1122-1123,1138-1141 |
|||
chars=1162-1273,7808-7813,7922-7923,7936-7957,7960-7965,7968-8005,8008-8013,8016-8023,8025,8027,8029,8031 |
|||
chars=8032-8061,8064-8116,8118-8132,8134-8147,8150-8155,8157-8175,8178-8180,8182-8190,8211-8213,8216-8218 |
|||
chars=8220-8222,8224-8226,8230,8240,8249-8250,8260,8304,8308-8313,8320-8329,8364,8366,8372,8377,8531-8542 |
|||
chars=8706,8710,8719,8721-8722,8725,8729-8730,8734,8747,8776,8800,8804-8805,9674 |
|||
|
|||
# imported icon images |
|||
@ -0,0 +1,70 @@ |
|||
#!/usr/bin/env python |
|||
|
|||
# This program source code file is part of KiCad, a free EDA CAD application. |
|||
# |
|||
# Copyright (C) 2016 CERN |
|||
# @author Maciej Suminski <maciej.suminski@cern.ch> |
|||
# |
|||
# This program is free software; you can redistribute it and/or |
|||
# modify it under the terms of the GNU General Public License |
|||
# as published by the Free Software Foundation; either version 2 |
|||
# of the License, or (at your option) any later version. |
|||
# |
|||
# This program is distributed in the hope that it will be useful, |
|||
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
# GNU General Public License for more details. |
|||
# |
|||
# You should have received a copy of the GNU General Public License |
|||
# along with this program; if not, you may find one here: |
|||
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html |
|||
# or you may search the http://www.gnu.org website for the version 2 license, |
|||
# or you may write to the Free Software Foundation, Inc., |
|||
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA |
|||
|
|||
# Converts a bitmap font atlas image in PNG format to raw pixel data stored |
|||
# in a C structure. |
|||
|
|||
import os |
|||
import png |
|||
import sys |
|||
|
|||
def convert(png_file): |
|||
r = png.Reader(file=open(png_file, 'rb')) |
|||
img = r.read() |
|||
|
|||
output = open(os.path.splitext(png_file)[0] + '_img.c', 'w') |
|||
|
|||
width = img[0] |
|||
height = img[1] |
|||
|
|||
# Header |
|||
output.write( |
|||
""" |
|||
/* generated with png2struct.py, do not modify by hand */ |
|||
|
|||
static const struct { |
|||
unsigned int width, height; |
|||
unsigned char pixels[%d * %d]; |
|||
} bitmap_font = { |
|||
""" % (width, height)); |
|||
|
|||
output.write('%d, %d,\n{' % (width, height)) |
|||
|
|||
for row in img[2]: |
|||
for p in row: |
|||
output.write('%d,' % p) |
|||
output.write('\n'); |
|||
|
|||
output.write('}\n};\n') |
|||
|
|||
output.close() |
|||
|
|||
#---------------------------------------------------------------------- |
|||
if __name__ == "__main__": |
|||
argc = len(sys.argv) |
|||
|
|||
if(argc == 2): |
|||
convert(sys.argv[1]) |
|||
else: |
|||
print("usage: %s <xml-file>" % sys.argv[0]) |
|||
Write
Preview
Loading…
Cancel
Save
Reference in new issue