From 48493f91bbcb5bd8ec7dae7075226c69e72a6e7f Mon Sep 17 00:00:00 2001 From: matthew Date: Thu, 14 Aug 2025 13:10:17 +1000 Subject: [PATCH] remove codegen (again) --- assets/data/atlas.json | 1 - build.sh | 7 - dub.json | 2 +- src/codegen/fonts.d | 825 ----------------------------------------- src/gears/main.d | 6 - src/shared/font.d | 42 +++ 6 files changed, 43 insertions(+), 840 deletions(-) delete mode 100644 assets/data/atlas.json delete mode 100644 src/codegen/fonts.d diff --git a/assets/data/atlas.json b/assets/data/atlas.json deleted file mode 100644 index a1862b6..0000000 --- a/assets/data/atlas.json +++ /dev/null @@ -1 +0,0 @@ -{"atlas":{"type":"softmask","size":58.53125,"width":256,"height":256,"yOrigin":"bottom"},"metrics":{"emSize":1,"lineHeight":1.4079999999999999,"ascender":1.105,"descender":-0.30299999999999999,"underlineY":-0.10000000000000001,"underlineThickness":0.050000000000000003},"glyphs":[{"unicode":32,"advance":0.20700000000000002},{"unicode":44,"advance":0.216,"planeBounds":{"left":0.033160437800320339,"bottom":-0.1793913507741591,"right":0.16983956219967969,"top":0.14522156967431932},"atlasBounds":{"left":247.5,"bottom":236.5,"right":255.5,"top":255.5}},{"unicode":45,"advance":0.373,"planeBounds":{"left":0.049820875600640691,"bottom":0.23064602242391885,"right":0.32317912439935936,"top":0.35024025627335825},"atlasBounds":{"left":40.5,"bottom":204.5,"right":56.5,"top":211.5}},{"unicode":46,"advance":0.216,"planeBounds":{"left":0.048202883075280305,"bottom":-0.0085424452749599585,"right":0.16779711692471971,"top":0.14522156967431929},"atlasBounds":{"left":247.5,"bottom":227.5,"right":254.5,"top":236.5}},{"unicode":48,"advance":0.46700000000000003,"planeBounds":{"left":0.019938868126001069,"bottom":-0.02562733582487987,"right":0.44706113187399893,"top":0.70902295782167657},"atlasBounds":{"left":149.5,"bottom":212.5,"right":174.5,"top":255.5}},{"unicode":49,"advance":0.28200000000000003,"planeBounds":{"left":0.003405766150560595,"bottom":-0.0085424452749599585,"right":0.2425942338494394,"top":0.69193806727175666},"atlasBounds":{"left":98.5,"bottom":35.5,"right":112.5,"top":76.5}},{"unicode":50,"advance":0.439,"planeBounds":{"left":0.014481313400961038,"bottom":-0.0085424452749599585,"right":0.42451868659903896,"top":0.70902295782167657},"atlasBounds":{"left":0.5,"bottom":118.5,"right":24.5,"top":160.5}},{"unicode":51,"advance":0.45600000000000002,"planeBounds":{"left":0.0099388681260010742,"bottom":-0.02562733582487987,"right":0.43706113187399892,"top":0.70902295782167657},"atlasBounds":{"left":174.5,"bottom":212.5,"right":199.5,"top":255.5}},{"unicode":52,"advance":0.46600000000000003,"planeBounds":{"left":0.011396422851041102,"bottom":-0.0085424452749599585,"right":0.45560357714895888,"top":0.69193806727175666},"atlasBounds":{"left":112.5,"bottom":35.5,"right":138.5,"top":76.5}},{"unicode":53,"advance":0.45400000000000001,"planeBounds":{"left":0.015438868126001062,"bottom":-0.02562733582487987,"right":0.44256113187399893,"top":0.69193806727175666},"atlasBounds":{"left":24.5,"bottom":118.5,"right":49.5,"top":160.5}},{"unicode":54,"advance":0.45600000000000002,"planeBounds":{"left":0.017938868126001085,"bottom":-0.02562733582487987,"right":0.44506113187399893,"top":0.70902295782167657},"atlasBounds":{"left":199.5,"bottom":212.5,"right":224.5,"top":255.5}},{"unicode":55,"advance":0.38600000000000001,"planeBounds":{"left":0.0040662039508809547,"bottom":-0.0085424452749599585,"right":0.37993379604911914,"top":0.69193806727175666},"atlasBounds":{"left":138.5,"bottom":35.5,"right":160.5,"top":76.5}},{"unicode":56,"advance":0.46400000000000002,"planeBounds":{"left":0.018438868126001075,"bottom":-0.02562733582487987,"right":0.44556113187399893,"top":0.70902295782167657},"atlasBounds":{"left":23.5,"bottom":160.5,"right":48.5,"top":203.5}},{"unicode":57,"advance":0.45600000000000002,"planeBounds":{"left":0.010938868126001085,"bottom":-0.02562733582487987,"right":0.43806113187399892,"top":0.70902295782167657},"atlasBounds":{"left":48.5,"bottom":160.5,"right":73.5,"top":203.5}},{"unicode":58,"advance":0.216,"planeBounds":{"left":0.048202883075280305,"bottom":-0.0085424452749599585,"right":0.16779711692471971,"top":0.52108916177255737},"atlasBounds":{"left":137.5,"bottom":3.5,"right":144.5,"top":34.5}},{"unicode":59,"advance":0.216,"planeBounds":{"left":0.033160437800320339,"bottom":-0.1793913507741591,"right":0.16983956219967969,"top":0.52108916177255737},"atlasBounds":{"left":243.5,"bottom":119.5,"right":251.5,"top":160.5}},{"unicode":65,"advance":0.53500000000000003,"planeBounds":{"left":0.011226641751201286,"bottom":-0.0085424452749599585,"right":0.52377335824879878,"top":0.70902295782167657},"atlasBounds":{"left":76.5,"bottom":76.5,"right":106.5,"top":118.5}},{"unicode":66,"advance":0.495,"planeBounds":{"left":0.04743886812600108,"bottom":-0.0085424452749599585,"right":0.47456113187399895,"top":0.70902295782167657},"atlasBounds":{"left":215.5,"bottom":76.5,"right":240.5,"top":118.5}},{"unicode":67,"advance":0.50800000000000001,"planeBounds":{"left":0.030353977576081149,"bottom":-0.02562733582487987,"right":0.49164602242391886,"top":0.72610784837159648},"atlasBounds":{"left":40.5,"bottom":211.5,"right":67.5,"top":255.5}},{"unicode":68,"advance":0.53500000000000003,"planeBounds":{"left":0.046853977576081153,"bottom":-0.0085424452749599585,"right":0.50814602242391882,"top":0.70902295782167657},"atlasBounds":{"left":26.5,"bottom":34.5,"right":53.5,"top":76.5}},{"unicode":69,"advance":0.45400000000000001,"planeBounds":{"left":0.047023758675920978,"bottom":-0.0085424452749599585,"right":0.43997624132407909,"top":0.70902295782167657},"atlasBounds":{"left":75.5,"bottom":34.5,"right":98.5,"top":76.5}},{"unicode":70,"advance":0.43099999999999999,"planeBounds":{"left":0.044066203950880949,"bottom":-0.0085424452749599585,"right":0.41993379604911912,"top":0.70902295782167657},"atlasBounds":{"left":53.5,"bottom":34.5,"right":75.5,"top":76.5}},{"unicode":71,"advance":0.53500000000000003,"planeBounds":{"left":0.025311532301121192,"bottom":-0.02562733582487987,"right":0.50368846769887887,"top":0.72610784837159648},"atlasBounds":{"left":67.5,"bottom":211.5,"right":95.5,"top":255.5}},{"unicode":72,"advance":0.54100000000000004,"planeBounds":{"left":0.048896422851041121,"bottom":-0.0085424452749599585,"right":0.49310357714895892,"top":0.70902295782167657},"atlasBounds":{"left":0.5,"bottom":34.5,"right":26.5,"top":76.5}},{"unicode":73,"advance":0.21099999999999999,"planeBounds":{"left":0.045702883075280303,"bottom":-0.0085424452749599585,"right":0.16529711692471971,"top":0.70902295782167657},"atlasBounds":{"left":236.5,"bottom":118.5,"right":243.5,"top":160.5}},{"unicode":74,"advance":0.438,"planeBounds":{"left":0.0070237586759209786,"bottom":-0.02562733582487987,"right":0.39997624132407905,"top":0.70902295782167657},"atlasBounds":{"left":73.5,"bottom":160.5,"right":96.5,"top":203.5}},{"unicode":75,"advance":0.50700000000000001,"planeBounds":{"left":0.051396422851041103,"bottom":-0.0085424452749599585,"right":0.49560357714895892,"top":0.70902295782167657},"atlasBounds":{"left":189.5,"bottom":76.5,"right":215.5,"top":118.5}},{"unicode":76,"advance":0.42999999999999999,"planeBounds":{"left":0.047566203950880938,"bottom":-0.0085424452749599585,"right":0.42343379604911913,"top":0.70902295782167657},"atlasBounds":{"left":167.5,"bottom":76.5,"right":189.5,"top":118.5}},{"unicode":77,"advance":0.68200000000000005,"planeBounds":{"left":0.050556860651361446,"bottom":-0.0085424452749599585,"right":0.6314431393486386,"top":0.70902295782167657},"atlasBounds":{"left":133.5,"bottom":76.5,"right":167.5,"top":118.5}},{"unicode":78,"advance":0.56000000000000005,"planeBounds":{"left":0.048853977576081141,"bottom":-0.0085424452749599585,"right":0.51014602242391882,"top":0.70902295782167657},"atlasBounds":{"left":106.5,"bottom":76.5,"right":133.5,"top":118.5}},{"unicode":79,"advance":0.53500000000000003,"planeBounds":{"left":0.028311532301121205,"bottom":-0.02562733582487987,"right":0.50668846769887887,"top":0.72610784837159648},"atlasBounds":{"left":95.5,"bottom":211.5,"right":123.5,"top":255.5}},{"unicode":80,"advance":0.47500000000000003,"planeBounds":{"left":0.047481313400961032,"bottom":-0.0085424452749599585,"right":0.45751868659903899,"top":0.70902295782167657},"atlasBounds":{"left":52.5,"bottom":76.5,"right":76.5,"top":118.5}},{"unicode":81,"advance":0.53500000000000003,"planeBounds":{"left":0.028311532301121205,"bottom":-0.14522156967431929,"right":0.50668846769887887,"top":0.72610784837159636},"atlasBounds":{"left":12.5,"bottom":204.5,"right":40.5,"top":255.5}},{"unicode":82,"advance":0.5,"planeBounds":{"left":0.046396422851041126,"bottom":-0.0085424452749599585,"right":0.49060357714895891,"top":0.70902295782167657},"atlasBounds":{"left":26.5,"bottom":76.5,"right":52.5,"top":118.5}},{"unicode":83,"advance":0.47500000000000003,"planeBounds":{"left":0.012396422851041127,"bottom":-0.02562733582487987,"right":0.45660357714895888,"top":0.72610784837159648},"atlasBounds":{"left":123.5,"bottom":211.5,"right":149.5,"top":255.5}},{"unicode":84,"advance":0.46600000000000003,"planeBounds":{"left":0.010896422851041121,"bottom":-0.0085424452749599585,"right":0.45510357714895888,"top":0.70902295782167657},"atlasBounds":{"left":0.5,"bottom":76.5,"right":26.5,"top":118.5}},{"unicode":85,"advance":0.52800000000000002,"planeBounds":{"left":0.043396422851041103,"bottom":-0.02562733582487987,"right":0.48760357714895891,"top":0.70902295782167657},"atlasBounds":{"left":121.5,"bottom":160.5,"right":147.5,"top":203.5}},{"unicode":86,"advance":0.52200000000000002,"planeBounds":{"left":0.0047266417512012993,"bottom":-0.0085424452749599585,"right":0.51727335824879883,"top":0.70902295782167657},"atlasBounds":{"left":184.5,"bottom":118.5,"right":214.5,"top":160.5}},{"unicode":87,"advance":0.76800000000000002,"planeBounds":{"left":0.0081324079017619059,"bottom":-0.0085424452749599585,"right":0.75986759209823829,"top":0.70902295782167657},"atlasBounds":{"left":140.5,"bottom":118.5,"right":184.5,"top":160.5}},{"unicode":88,"advance":0.51300000000000001,"planeBounds":{"left":0.0087690870261612347,"bottom":-0.0085424452749599585,"right":0.50423091297383882,"top":0.70902295782167657},"atlasBounds":{"left":111.5,"bottom":118.5,"right":140.5,"top":160.5}},{"unicode":89,"advance":0.52400000000000002,"planeBounds":{"left":0.0057266417512012941,"bottom":-0.0085424452749599585,"right":0.51827335824879883,"top":0.70902295782167657},"atlasBounds":{"left":81.5,"bottom":118.5,"right":111.5,"top":160.5}},{"unicode":90,"advance":0.45200000000000001,"planeBounds":{"left":0.011438868126001062,"bottom":-0.0085424452749599585,"right":0.43856113187399892,"top":0.70902295782167657},"atlasBounds":{"left":56.5,"bottom":118.5,"right":81.5,"top":160.5}},{"unicode":97,"advance":0.42699999999999999,"planeBounds":{"left":0.0090237586759209926,"bottom":-0.02562733582487987,"right":0.40197624132407905,"top":0.52108916177255737},"atlasBounds":{"left":114.5,"bottom":2.5,"right":137.5,"top":34.5}},{"unicode":98,"advance":0.45700000000000002,"planeBounds":{"left":0.043023758675920981,"bottom":-0.02562733582487987,"right":0.43597624132407908,"top":0.70902295782167657},"atlasBounds":{"left":147.5,"bottom":160.5,"right":170.5,"top":203.5}},{"unicode":99,"advance":0.42299999999999999,"planeBounds":{"left":0.018023758675921001,"bottom":-0.02562733582487987,"right":0.41097624132407906,"top":0.52108916177255737},"atlasBounds":{"left":24.5,"bottom":2.5,"right":47.5,"top":34.5}},{"unicode":100,"advance":0.45600000000000002,"planeBounds":{"left":0.021023758675920986,"bottom":-0.02562733582487987,"right":0.41397624132407906,"top":0.70902295782167657},"atlasBounds":{"left":209.5,"bottom":160.5,"right":232.5,"top":203.5}},{"unicode":101,"advance":0.42999999999999999,"planeBounds":{"left":0.021023758675920986,"bottom":-0.02562733582487987,"right":0.41397624132407906,"top":0.52108916177255737},"atlasBounds":{"left":69.5,"bottom":2.5,"right":92.5,"top":34.5}},{"unicode":102,"advance":0.28300000000000003,"planeBounds":{"left":0.0093208756006406789,"bottom":-0.0085424452749599585,"right":0.28267912439935938,"top":0.72610784837159648},"atlasBounds":{"left":193.5,"bottom":160.5,"right":209.5,"top":203.5}},{"unicode":103,"advance":0.44800000000000001,"planeBounds":{"left":0.020523758675920975,"bottom":-0.21356113187399894,"right":0.41347624132407906,"top":0.52108916177255737},"atlasBounds":{"left":170.5,"bottom":160.5,"right":193.5,"top":203.5}},{"unicode":104,"advance":0.44900000000000001,"planeBounds":{"left":0.039566203950880938,"bottom":-0.0085424452749599585,"right":0.41543379604911912,"top":0.70902295782167657},"atlasBounds":{"left":214.5,"bottom":118.5,"right":236.5,"top":160.5}},{"unicode":105,"advance":0.184,"planeBounds":{"left":0.032202883075280304,"bottom":-0.0085424452749599585,"right":0.15179711692471973,"top":0.67485317672183676},"atlasBounds":{"left":176.5,"bottom":36.5,"right":183.5,"top":76.5}},{"unicode":106,"advance":0.187,"planeBounds":{"left":-0.051009343299519477,"bottom":-0.21356113187399894,"right":0.15400934329951949,"top":0.67485317672183676},"atlasBounds":{"left":0.5,"bottom":203.5,"right":12.5,"top":255.5}},{"unicode":107,"advance":0.434,"planeBounds":{"left":0.042023758675920987,"bottom":-0.0085424452749599585,"right":0.43497624132407908,"top":0.70902295782167657},"atlasBounds":{"left":232.5,"bottom":161.5,"right":255.5,"top":203.5}},{"unicode":108,"advance":0.19,"planeBounds":{"left":0.035702883075280308,"bottom":-0.0085424452749599585,"right":0.15529711692471973,"top":0.70902295782167657},"atlasBounds":{"left":49.5,"bottom":118.5,"right":56.5,"top":160.5}},{"unicode":109,"advance":0.69000000000000006,"planeBounds":{"left":0.039471970101441538,"bottom":-0.0085424452749599585,"right":0.65452802989855852,"top":0.52108916177255737},"atlasBounds":{"left":169.5,"bottom":3.5,"right":205.5,"top":34.5}},{"unicode":110,"advance":0.44600000000000001,"planeBounds":{"left":0.036566203950880942,"bottom":-0.0085424452749599585,"right":0.41243379604911912,"top":0.52108916177255737},"atlasBounds":{"left":183.5,"bottom":45.5,"right":205.5,"top":76.5}},{"unicode":111,"advance":0.442,"planeBounds":{"left":0.015981313400961025,"bottom":-0.02562733582487987,"right":0.42601868659903896,"top":0.52108916177255737},"atlasBounds":{"left":0.5,"bottom":2.5,"right":24.5,"top":34.5}},{"unicode":112,"advance":0.45700000000000002,"planeBounds":{"left":0.043023758675920981,"bottom":-0.21356113187399894,"right":0.43597624132407908,"top":0.52108916177255737},"atlasBounds":{"left":0.5,"bottom":160.5,"right":23.5,"top":203.5}},{"unicode":113,"advance":0.45500000000000002,"planeBounds":{"left":0.021023758675920986,"bottom":-0.21356113187399894,"right":0.41397624132407906,"top":0.52108916177255737},"atlasBounds":{"left":224.5,"bottom":212.5,"right":247.5,"top":255.5}},{"unicode":114,"advance":0.29799999999999999,"planeBounds":{"left":0.038363320875600654,"bottom":-0.0085424452749599585,"right":0.29463667912439939,"top":0.52108916177255737},"atlasBounds":{"left":240.5,"bottom":87.5,"right":255.5,"top":118.5}},{"unicode":115,"advance":0.40000000000000002,"planeBounds":{"left":0.01106620395088093,"bottom":-0.02562733582487987,"right":0.38693379604911909,"top":0.52108916177255737},"atlasBounds":{"left":47.5,"bottom":2.5,"right":69.5,"top":34.5}},{"unicode":116,"advance":0.29299999999999998,"planeBounds":{"left":0.0043208756006406848,"bottom":-0.02562733582487987,"right":0.27767912439935938,"top":0.65776828617191674},"atlasBounds":{"left":160.5,"bottom":36.5,"right":176.5,"top":76.5}},{"unicode":117,"advance":0.44,"planeBounds":{"left":0.029566203950880946,"bottom":-0.02562733582487987,"right":0.40543379604911911,"top":0.52108916177255737},"atlasBounds":{"left":92.5,"bottom":2.5,"right":114.5,"top":34.5}},{"unicode":118,"advance":0.41899999999999998,"planeBounds":{"left":-0.0040611318739989192,"bottom":-0.0085424452749599585,"right":0.42306113187399896,"top":0.52108916177255737},"atlasBounds":{"left":144.5,"bottom":3.5,"right":169.5,"top":34.5}},{"unicode":119,"advance":0.65800000000000003,"planeBounds":{"left":0.004387079551521623,"bottom":-0.0085424452749599585,"right":0.65361292044847852,"top":0.52108916177255737},"atlasBounds":{"left":205.5,"bottom":45.5,"right":243.5,"top":76.5}},{"unicode":120,"advance":0.41200000000000003,"planeBounds":{"left":0.00098131340096103861,"bottom":-0.0085424452749599585,"right":0.41101868659903901,"top":0.52108916177255737},"atlasBounds":{"left":205.5,"bottom":3.5,"right":229.5,"top":34.5}},{"unicode":121,"advance":0.42099999999999999,"planeBounds":{"left":-0.0025611318739989439,"bottom":-0.21356113187399894,"right":0.42456113187399896,"top":0.52108916177255737},"atlasBounds":{"left":96.5,"bottom":160.5,"right":121.5,"top":203.5}},{"unicode":122,"advance":0.38300000000000001,"planeBounds":{"left":0.002066203950880949,"bottom":-0.0085424452749599585,"right":0.37793379604911914,"top":0.52108916177255737},"atlasBounds":{"left":229.5,"bottom":3.5,"right":251.5,"top":34.5}}],"kerning":[]} diff --git a/build.sh b/build.sh index 100782f..bf351a9 100755 --- a/build.sh +++ b/build.sh @@ -95,10 +95,3 @@ if ! [ -f build/libcglm.a ]; then rm $obj fi -if ! [ -f build/atlas.png ]; then - msdf-atlas-gen -font assets/fonts/NuberNextCondensed-DemiBold.otf -dimensions 256 256 -type softmask -imageout build/atlas.png -json build/atlas.json -fi - -cp build/atlas.png assets/textures/atlas.png -mkdir -p assets/data -cp build/atlas.json assets/data/atlas.json diff --git a/dub.json b/dub.json index fae2577..35d8c46 100644 --- a/dub.json +++ b/dub.json @@ -13,7 +13,7 @@ "sourcePaths": ["src/gears", "src/codegen", "src/shared", "external/xxhash", "external/inteli"], "libs-linux": ["xcb", "X11", "X11-xcb", "vulkan", "stdc++", "xcb-xfixes", "freetype"], "libs-windows": [], - "preGenerateCommands-linux": ["./build.sh", "build/Packer"], + "preGenerateCommands-linux": ["./build.sh"], "preGenerateCommands-windows": [], "dflags": ["-Xcc=-mno-sse", "-P-I/usr/include/freetype2"], "dflags-dmd": ["-P=-DSTBI_NO_SIMD"] diff --git a/src/codegen/fonts.d b/src/codegen/fonts.d deleted file mode 100644 index 9c2fc9d..0000000 --- a/src/codegen/fonts.d +++ /dev/null @@ -1,825 +0,0 @@ -import util; - -static immutable FontAtlas FONT_ATLAS = { - type: AtlasType.SoftMask, - size: 58.531250, - width: 256, - height: 256, - y_origin: YOrigin.Bottom, - em_size: 1.000000, - line_height: 1.408000, - ascender: 1.105000, - descender: -0.303000, - underline_y: -0.100000, - underline_thickness: 0.050000, - glyphs: [ - { - ch: ' ', - advance: 0.207000, - }, - { - ch: ',', - advance: 0.216000, - plane_left: 0.033160, - plane_bottom: -0.179391, - plane_right: 0.169840, - plane_top: 0.145222, - atlas_left: 247.500000, - atlas_bottom: 19.500000, - atlas_right: 255.500000, - atlas_top: 0.500000, - }, - { - ch: '-', - advance: 0.373000, - plane_left: 0.049821, - plane_bottom: 0.230646, - plane_right: 0.323179, - plane_top: 0.350240, - atlas_left: 40.500000, - atlas_bottom: 51.500000, - atlas_right: 56.500000, - atlas_top: 44.500000, - }, - { - ch: '.', - advance: 0.216000, - plane_left: 0.048203, - plane_bottom: -0.008542, - plane_right: 0.167797, - plane_top: 0.145222, - atlas_left: 247.500000, - atlas_bottom: 28.500000, - atlas_right: 254.500000, - atlas_top: 19.500000, - }, - { - ch: '0', - advance: 0.467000, - plane_left: 0.019939, - plane_bottom: -0.025627, - plane_right: 0.447061, - plane_top: 0.709023, - atlas_left: 149.500000, - atlas_bottom: 43.500000, - atlas_right: 174.500000, - atlas_top: 0.500000, - }, - { - ch: '1', - advance: 0.282000, - plane_left: 0.003406, - plane_bottom: -0.008542, - plane_right: 0.242594, - plane_top: 0.691938, - atlas_left: 98.500000, - atlas_bottom: 220.500000, - atlas_right: 112.500000, - atlas_top: 179.500000, - }, - { - ch: '2', - advance: 0.439000, - plane_left: 0.014481, - plane_bottom: -0.008542, - plane_right: 0.424519, - plane_top: 0.709023, - atlas_left: 0.500000, - atlas_bottom: 137.500000, - atlas_right: 24.500000, - atlas_top: 95.500000, - }, - { - ch: '3', - advance: 0.456000, - plane_left: 0.009939, - plane_bottom: -0.025627, - plane_right: 0.437061, - plane_top: 0.709023, - atlas_left: 174.500000, - atlas_bottom: 43.500000, - atlas_right: 199.500000, - atlas_top: 0.500000, - }, - { - ch: '4', - advance: 0.466000, - plane_left: 0.011396, - plane_bottom: -0.008542, - plane_right: 0.455604, - plane_top: 0.691938, - atlas_left: 112.500000, - atlas_bottom: 220.500000, - atlas_right: 138.500000, - atlas_top: 179.500000, - }, - { - ch: '5', - advance: 0.454000, - plane_left: 0.015439, - plane_bottom: -0.025627, - plane_right: 0.442561, - plane_top: 0.691938, - atlas_left: 24.500000, - atlas_bottom: 137.500000, - atlas_right: 49.500000, - atlas_top: 95.500000, - }, - { - ch: '6', - advance: 0.456000, - plane_left: 0.017939, - plane_bottom: -0.025627, - plane_right: 0.445061, - plane_top: 0.709023, - atlas_left: 199.500000, - atlas_bottom: 43.500000, - atlas_right: 224.500000, - atlas_top: 0.500000, - }, - { - ch: '7', - advance: 0.386000, - plane_left: 0.004066, - plane_bottom: -0.008542, - plane_right: 0.379934, - plane_top: 0.691938, - atlas_left: 138.500000, - atlas_bottom: 220.500000, - atlas_right: 160.500000, - atlas_top: 179.500000, - }, - { - ch: '8', - advance: 0.464000, - plane_left: 0.018439, - plane_bottom: -0.025627, - plane_right: 0.445561, - plane_top: 0.709023, - atlas_left: 23.500000, - atlas_bottom: 95.500000, - atlas_right: 48.500000, - atlas_top: 52.500000, - }, - { - ch: '9', - advance: 0.456000, - plane_left: 0.010939, - plane_bottom: -0.025627, - plane_right: 0.438061, - plane_top: 0.709023, - atlas_left: 48.500000, - atlas_bottom: 95.500000, - atlas_right: 73.500000, - atlas_top: 52.500000, - }, - { - ch: ':', - advance: 0.216000, - plane_left: 0.048203, - plane_bottom: -0.008542, - plane_right: 0.167797, - plane_top: 0.521089, - atlas_left: 137.500000, - atlas_bottom: 252.500000, - atlas_right: 144.500000, - atlas_top: 221.500000, - }, - { - ch: ';', - advance: 0.216000, - plane_left: 0.033160, - plane_bottom: -0.179391, - plane_right: 0.169840, - plane_top: 0.521089, - atlas_left: 243.500000, - atlas_bottom: 136.500000, - atlas_right: 251.500000, - atlas_top: 95.500000, - }, - { - ch: 'A', - advance: 0.535000, - plane_left: 0.011227, - plane_bottom: -0.008542, - plane_right: 0.523773, - plane_top: 0.709023, - atlas_left: 76.500000, - atlas_bottom: 179.500000, - atlas_right: 106.500000, - atlas_top: 137.500000, - }, - { - ch: 'B', - advance: 0.495000, - plane_left: 0.047439, - plane_bottom: -0.008542, - plane_right: 0.474561, - plane_top: 0.709023, - atlas_left: 215.500000, - atlas_bottom: 179.500000, - atlas_right: 240.500000, - atlas_top: 137.500000, - }, - { - ch: 'C', - advance: 0.508000, - plane_left: 0.030354, - plane_bottom: -0.025627, - plane_right: 0.491646, - plane_top: 0.726108, - atlas_left: 40.500000, - atlas_bottom: 44.500000, - atlas_right: 67.500000, - atlas_top: 0.500000, - }, - { - ch: 'D', - advance: 0.535000, - plane_left: 0.046854, - plane_bottom: -0.008542, - plane_right: 0.508146, - plane_top: 0.709023, - atlas_left: 26.500000, - atlas_bottom: 221.500000, - atlas_right: 53.500000, - atlas_top: 179.500000, - }, - { - ch: 'E', - advance: 0.454000, - plane_left: 0.047024, - plane_bottom: -0.008542, - plane_right: 0.439976, - plane_top: 0.709023, - atlas_left: 75.500000, - atlas_bottom: 221.500000, - atlas_right: 98.500000, - atlas_top: 179.500000, - }, - { - ch: 'F', - advance: 0.431000, - plane_left: 0.044066, - plane_bottom: -0.008542, - plane_right: 0.419934, - plane_top: 0.709023, - atlas_left: 53.500000, - atlas_bottom: 221.500000, - atlas_right: 75.500000, - atlas_top: 179.500000, - }, - { - ch: 'G', - advance: 0.535000, - plane_left: 0.025312, - plane_bottom: -0.025627, - plane_right: 0.503688, - plane_top: 0.726108, - atlas_left: 67.500000, - atlas_bottom: 44.500000, - atlas_right: 95.500000, - atlas_top: 0.500000, - }, - { - ch: 'H', - advance: 0.541000, - plane_left: 0.048896, - plane_bottom: -0.008542, - plane_right: 0.493104, - plane_top: 0.709023, - atlas_left: 0.500000, - atlas_bottom: 221.500000, - atlas_right: 26.500000, - atlas_top: 179.500000, - }, - { - ch: 'I', - advance: 0.211000, - plane_left: 0.045703, - plane_bottom: -0.008542, - plane_right: 0.165297, - plane_top: 0.709023, - atlas_left: 236.500000, - atlas_bottom: 137.500000, - atlas_right: 243.500000, - atlas_top: 95.500000, - }, - { - ch: 'J', - advance: 0.438000, - plane_left: 0.007024, - plane_bottom: -0.025627, - plane_right: 0.399976, - plane_top: 0.709023, - atlas_left: 73.500000, - atlas_bottom: 95.500000, - atlas_right: 96.500000, - atlas_top: 52.500000, - }, - { - ch: 'K', - advance: 0.507000, - plane_left: 0.051396, - plane_bottom: -0.008542, - plane_right: 0.495604, - plane_top: 0.709023, - atlas_left: 189.500000, - atlas_bottom: 179.500000, - atlas_right: 215.500000, - atlas_top: 137.500000, - }, - { - ch: 'L', - advance: 0.430000, - plane_left: 0.047566, - plane_bottom: -0.008542, - plane_right: 0.423434, - plane_top: 0.709023, - atlas_left: 167.500000, - atlas_bottom: 179.500000, - atlas_right: 189.500000, - atlas_top: 137.500000, - }, - { - ch: 'M', - advance: 0.682000, - plane_left: 0.050557, - plane_bottom: -0.008542, - plane_right: 0.631443, - plane_top: 0.709023, - atlas_left: 133.500000, - atlas_bottom: 179.500000, - atlas_right: 167.500000, - atlas_top: 137.500000, - }, - { - ch: 'N', - advance: 0.560000, - plane_left: 0.048854, - plane_bottom: -0.008542, - plane_right: 0.510146, - plane_top: 0.709023, - atlas_left: 106.500000, - atlas_bottom: 179.500000, - atlas_right: 133.500000, - atlas_top: 137.500000, - }, - { - ch: 'O', - advance: 0.535000, - plane_left: 0.028312, - plane_bottom: -0.025627, - plane_right: 0.506688, - plane_top: 0.726108, - atlas_left: 95.500000, - atlas_bottom: 44.500000, - atlas_right: 123.500000, - atlas_top: 0.500000, - }, - { - ch: 'P', - advance: 0.475000, - plane_left: 0.047481, - plane_bottom: -0.008542, - plane_right: 0.457519, - plane_top: 0.709023, - atlas_left: 52.500000, - atlas_bottom: 179.500000, - atlas_right: 76.500000, - atlas_top: 137.500000, - }, - { - ch: 'Q', - advance: 0.535000, - plane_left: 0.028312, - plane_bottom: -0.145222, - plane_right: 0.506688, - plane_top: 0.726108, - atlas_left: 12.500000, - atlas_bottom: 51.500000, - atlas_right: 40.500000, - atlas_top: 0.500000, - }, - { - ch: 'R', - advance: 0.500000, - plane_left: 0.046396, - plane_bottom: -0.008542, - plane_right: 0.490604, - plane_top: 0.709023, - atlas_left: 26.500000, - atlas_bottom: 179.500000, - atlas_right: 52.500000, - atlas_top: 137.500000, - }, - { - ch: 'S', - advance: 0.475000, - plane_left: 0.012396, - plane_bottom: -0.025627, - plane_right: 0.456604, - plane_top: 0.726108, - atlas_left: 123.500000, - atlas_bottom: 44.500000, - atlas_right: 149.500000, - atlas_top: 0.500000, - }, - { - ch: 'T', - advance: 0.466000, - plane_left: 0.010896, - plane_bottom: -0.008542, - plane_right: 0.455104, - plane_top: 0.709023, - atlas_left: 0.500000, - atlas_bottom: 179.500000, - atlas_right: 26.500000, - atlas_top: 137.500000, - }, - { - ch: 'U', - advance: 0.528000, - plane_left: 0.043396, - plane_bottom: -0.025627, - plane_right: 0.487604, - plane_top: 0.709023, - atlas_left: 121.500000, - atlas_bottom: 95.500000, - atlas_right: 147.500000, - atlas_top: 52.500000, - }, - { - ch: 'V', - advance: 0.522000, - plane_left: 0.004727, - plane_bottom: -0.008542, - plane_right: 0.517273, - plane_top: 0.709023, - atlas_left: 184.500000, - atlas_bottom: 137.500000, - atlas_right: 214.500000, - atlas_top: 95.500000, - }, - { - ch: 'W', - advance: 0.768000, - plane_left: 0.008132, - plane_bottom: -0.008542, - plane_right: 0.759868, - plane_top: 0.709023, - atlas_left: 140.500000, - atlas_bottom: 137.500000, - atlas_right: 184.500000, - atlas_top: 95.500000, - }, - { - ch: 'X', - advance: 0.513000, - plane_left: 0.008769, - plane_bottom: -0.008542, - plane_right: 0.504231, - plane_top: 0.709023, - atlas_left: 111.500000, - atlas_bottom: 137.500000, - atlas_right: 140.500000, - atlas_top: 95.500000, - }, - { - ch: 'Y', - advance: 0.524000, - plane_left: 0.005727, - plane_bottom: -0.008542, - plane_right: 0.518273, - plane_top: 0.709023, - atlas_left: 81.500000, - atlas_bottom: 137.500000, - atlas_right: 111.500000, - atlas_top: 95.500000, - }, - { - ch: 'Z', - advance: 0.452000, - plane_left: 0.011439, - plane_bottom: -0.008542, - plane_right: 0.438561, - plane_top: 0.709023, - atlas_left: 56.500000, - atlas_bottom: 137.500000, - atlas_right: 81.500000, - atlas_top: 95.500000, - }, - { - ch: 'a', - advance: 0.427000, - plane_left: 0.009024, - plane_bottom: -0.025627, - plane_right: 0.401976, - plane_top: 0.521089, - atlas_left: 114.500000, - atlas_bottom: 253.500000, - atlas_right: 137.500000, - atlas_top: 221.500000, - }, - { - ch: 'b', - advance: 0.457000, - plane_left: 0.043024, - plane_bottom: -0.025627, - plane_right: 0.435976, - plane_top: 0.709023, - atlas_left: 147.500000, - atlas_bottom: 95.500000, - atlas_right: 170.500000, - atlas_top: 52.500000, - }, - { - ch: 'c', - advance: 0.423000, - plane_left: 0.018024, - plane_bottom: -0.025627, - plane_right: 0.410976, - plane_top: 0.521089, - atlas_left: 24.500000, - atlas_bottom: 253.500000, - atlas_right: 47.500000, - atlas_top: 221.500000, - }, - { - ch: 'd', - advance: 0.456000, - plane_left: 0.021024, - plane_bottom: -0.025627, - plane_right: 0.413976, - plane_top: 0.709023, - atlas_left: 209.500000, - atlas_bottom: 95.500000, - atlas_right: 232.500000, - atlas_top: 52.500000, - }, - { - ch: 'e', - advance: 0.430000, - plane_left: 0.021024, - plane_bottom: -0.025627, - plane_right: 0.413976, - plane_top: 0.521089, - atlas_left: 69.500000, - atlas_bottom: 253.500000, - atlas_right: 92.500000, - atlas_top: 221.500000, - }, - { - ch: 'f', - advance: 0.283000, - plane_left: 0.009321, - plane_bottom: -0.008542, - plane_right: 0.282679, - plane_top: 0.726108, - atlas_left: 193.500000, - atlas_bottom: 95.500000, - atlas_right: 209.500000, - atlas_top: 52.500000, - }, - { - ch: 'g', - advance: 0.448000, - plane_left: 0.020524, - plane_bottom: -0.213561, - plane_right: 0.413476, - plane_top: 0.521089, - atlas_left: 170.500000, - atlas_bottom: 95.500000, - atlas_right: 193.500000, - atlas_top: 52.500000, - }, - { - ch: 'h', - advance: 0.449000, - plane_left: 0.039566, - plane_bottom: -0.008542, - plane_right: 0.415434, - plane_top: 0.709023, - atlas_left: 214.500000, - atlas_bottom: 137.500000, - atlas_right: 236.500000, - atlas_top: 95.500000, - }, - { - ch: 'i', - advance: 0.184000, - plane_left: 0.032203, - plane_bottom: -0.008542, - plane_right: 0.151797, - plane_top: 0.674853, - atlas_left: 176.500000, - atlas_bottom: 219.500000, - atlas_right: 183.500000, - atlas_top: 179.500000, - }, - { - ch: 'j', - advance: 0.187000, - plane_left: -0.051009, - plane_bottom: -0.213561, - plane_right: 0.154009, - plane_top: 0.674853, - atlas_left: 0.500000, - atlas_bottom: 52.500000, - atlas_right: 12.500000, - atlas_top: 0.500000, - }, - { - ch: 'k', - advance: 0.434000, - plane_left: 0.042024, - plane_bottom: -0.008542, - plane_right: 0.434976, - plane_top: 0.709023, - atlas_left: 232.500000, - atlas_bottom: 94.500000, - atlas_right: 255.500000, - atlas_top: 52.500000, - }, - { - ch: 'l', - advance: 0.190000, - plane_left: 0.035703, - plane_bottom: -0.008542, - plane_right: 0.155297, - plane_top: 0.709023, - atlas_left: 49.500000, - atlas_bottom: 137.500000, - atlas_right: 56.500000, - atlas_top: 95.500000, - }, - { - ch: 'm', - advance: 0.690000, - plane_left: 0.039472, - plane_bottom: -0.008542, - plane_right: 0.654528, - plane_top: 0.521089, - atlas_left: 169.500000, - atlas_bottom: 252.500000, - atlas_right: 205.500000, - atlas_top: 221.500000, - }, - { - ch: 'n', - advance: 0.446000, - plane_left: 0.036566, - plane_bottom: -0.008542, - plane_right: 0.412434, - plane_top: 0.521089, - atlas_left: 183.500000, - atlas_bottom: 210.500000, - atlas_right: 205.500000, - atlas_top: 179.500000, - }, - { - ch: 'o', - advance: 0.442000, - plane_left: 0.015981, - plane_bottom: -0.025627, - plane_right: 0.426019, - plane_top: 0.521089, - atlas_left: 0.500000, - atlas_bottom: 253.500000, - atlas_right: 24.500000, - atlas_top: 221.500000, - }, - { - ch: 'p', - advance: 0.457000, - plane_left: 0.043024, - plane_bottom: -0.213561, - plane_right: 0.435976, - plane_top: 0.521089, - atlas_left: 0.500000, - atlas_bottom: 95.500000, - atlas_right: 23.500000, - atlas_top: 52.500000, - }, - { - ch: 'q', - advance: 0.455000, - plane_left: 0.021024, - plane_bottom: -0.213561, - plane_right: 0.413976, - plane_top: 0.521089, - atlas_left: 224.500000, - atlas_bottom: 43.500000, - atlas_right: 247.500000, - atlas_top: 0.500000, - }, - { - ch: 'r', - advance: 0.298000, - plane_left: 0.038363, - plane_bottom: -0.008542, - plane_right: 0.294637, - plane_top: 0.521089, - atlas_left: 240.500000, - atlas_bottom: 168.500000, - atlas_right: 255.500000, - atlas_top: 137.500000, - }, - { - ch: 's', - advance: 0.400000, - plane_left: 0.011066, - plane_bottom: -0.025627, - plane_right: 0.386934, - plane_top: 0.521089, - atlas_left: 47.500000, - atlas_bottom: 253.500000, - atlas_right: 69.500000, - atlas_top: 221.500000, - }, - { - ch: 't', - advance: 0.293000, - plane_left: 0.004321, - plane_bottom: -0.025627, - plane_right: 0.277679, - plane_top: 0.657768, - atlas_left: 160.500000, - atlas_bottom: 219.500000, - atlas_right: 176.500000, - atlas_top: 179.500000, - }, - { - ch: 'u', - advance: 0.440000, - plane_left: 0.029566, - plane_bottom: -0.025627, - plane_right: 0.405434, - plane_top: 0.521089, - atlas_left: 92.500000, - atlas_bottom: 253.500000, - atlas_right: 114.500000, - atlas_top: 221.500000, - }, - { - ch: 'v', - advance: 0.419000, - plane_left: -0.004061, - plane_bottom: -0.008542, - plane_right: 0.423061, - plane_top: 0.521089, - atlas_left: 144.500000, - atlas_bottom: 252.500000, - atlas_right: 169.500000, - atlas_top: 221.500000, - }, - { - ch: 'w', - advance: 0.658000, - plane_left: 0.004387, - plane_bottom: -0.008542, - plane_right: 0.653613, - plane_top: 0.521089, - atlas_left: 205.500000, - atlas_bottom: 210.500000, - atlas_right: 243.500000, - atlas_top: 179.500000, - }, - { - ch: 'x', - advance: 0.412000, - plane_left: 0.000981, - plane_bottom: -0.008542, - plane_right: 0.411019, - plane_top: 0.521089, - atlas_left: 205.500000, - atlas_bottom: 252.500000, - atlas_right: 229.500000, - atlas_top: 221.500000, - }, - { - ch: 'y', - advance: 0.421000, - plane_left: -0.002561, - plane_bottom: -0.213561, - plane_right: 0.424561, - plane_top: 0.521089, - atlas_left: 96.500000, - atlas_bottom: 95.500000, - atlas_right: 121.500000, - atlas_top: 52.500000, - }, - { - ch: 'z', - advance: 0.383000, - plane_left: 0.002066, - plane_bottom: -0.008542, - plane_right: 0.377934, - plane_top: 0.521089, - atlas_left: 229.500000, - atlas_bottom: 252.500000, - atlas_right: 251.500000, - atlas_top: 221.500000, - }, - ], -}; diff --git a/src/gears/main.d b/src/gears/main.d index 98d34da..4848f9e 100644 --- a/src/gears/main.d +++ b/src/gears/main.d @@ -9,12 +9,6 @@ import core.simd; import math; import core.stdc.string : memcpy; -import font; -import alloc; -import assets; - -FontAtlasBuf FONT_ATLAS_TEST; - // TODO: // 1. Determine how to better handle inputs // 2. Set up multisampling diff --git a/src/shared/font.d b/src/shared/font.d index 52cb650..9b4b0cf 100644 --- a/src/shared/font.d +++ b/src/shared/font.d @@ -3,6 +3,48 @@ import includes; import util; import alloc; +enum AtlasType +{ + None = 0, + SoftMask, +} + +enum YOrigin +{ + None = 0, + Bottom, +} + +struct FontAtlas +{ + AtlasType type; + f32 size; + u32 width; + u32 height; + YOrigin y_origin; + f32 em_size; + f32 line_height; + f32 ascender; + f32 descender; + f32 underline_y; + f32 underline_thickness; + Glyph[] glyphs; +} + +struct Glyph +{ + dchar ch; + f32 advance; + f32 plane_left; + f32 plane_bottom; + f32 plane_right; + f32 plane_top; + f32 atlas_left; + f32 atlas_bottom; + f32 atlas_right; + f32 atlas_top; +} + FT_Library FT_LIB; alias FontFace = FT_Face;