From d8caa280b137a6f2a1f9acd29fce447a33228296 Mon Sep 17 00:00:00 2001 From: Jeffrey Pfau Date: Sun, 23 Aug 2015 00:57:22 -0700 Subject: [PATCH] GUI: Add lowercase and font metrics --- res/font.png | Bin 5383 -> 5639 bytes src/util/gui/font-metrics.c | 137 ++++++++++++++++++++++++++++++++++++ src/util/gui/font-metrics.h | 13 ++++ src/util/gui/font.h | 11 +++ 4 files changed, 161 insertions(+) create mode 100644 src/util/gui/font-metrics.c create mode 100644 src/util/gui/font-metrics.h diff --git a/res/font.png b/res/font.png index 73b9893c564395a0318693a381cdc5ee3dba44a5..70adb6bd1e3613db5471e72ebda85ed78020b917 100644 GIT binary patch delta 2117 zcmV-L2)g%&Du*nv+6{jQ7fD1xRCwC#Tv?LbFbD<4_dhb^!%K??LUOx1snp0-(}}Fb z(i0#yn}vS&_1o9K09XJl02TlXfCaz;U;(fISO6>l761!?1;7Ge0k8mA04x9&01JQx zzye?aumD&9EC3b&3xEZ{Z@9LPjH3T9nA^mXl!)Z`b=9vj8?k>imD2uuG#40NsC#2j z{i!{ZiUOF3?E1f5zpq=bvNACdtDGfLA=0aXGSPmo?eC_;UT{^##}TL@k=67x4y^&kK(QE^M^ zj-Hmqd?k^mkmr9Ka87TV*%47cMc)5_jO}d9Oh$hFVfXD00gD&1>P5{np}YoFP)W|IuiqW~+n$ov^_>`2%#vS!mnAFO|0LQ&(fDy3x8-ijo}hwJI= z>lcwJ`PcGoK~@@0p<9OV#LgmQ2NIn9*YSTe(Fs4 zNoK`02b`qLO$WA1B9QH{vR&}9b$F$HWLs;atzq_5YFy*xm()ItKcZm%b6Y^)emJje z@ddyFU^#z8q7c(qM0-7!o%Nq+??Q9+nNUS37o}cp8c0uQZ;jgVQq{pc$NJD7R6_=Z z6x)yL#Y21ZI>8&`m)d8bFi|&_8-Htb zb+7HCX`moGv_xM*8K$M+0;$F)5+Hdjd+i%33=w~@X8i3M!MOW$BGT5tHxI|Pe(n3L zG@%M9Yy}+xT8w6iN1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v4~;uQDxtG{RI2f};gB)@ z0I?iQ=1`(peI)^^@!S(OU%;l#g*tGlDRh?sj=#`-A#Rp^H*kaxqeG#XrA6*DjHa7Uthk5(OFMZ z65z$TQ4GLoFVFmlcjNuX`yyjWi1F5@27v-8n%A{*QozJsU$Up8W7*g11P5XQ(rIh9 ziy|r@g&VTc5(Y5ZAJ70a01d#?{Q=df`+)oarwBhMKVS>G4^-1z{sMm}A_FV$8(2L@ zZbc4}$>s;pWc=+^)bwngmLH(;dSZTnMfiF70hBx8{@(n6ZK@xX`TnUrR>=TMbGQ8q z6#{{Yde0wF`vmLqujB_Tn&W?Qen8B@ogdJ~Py^5aGysqA2mD@sK=^@!_mqMk%@1JA z!vqMh7`OY`{D3@Iy8eG9s^85IxN~vfVlV*wR(`7$k^8*&5#bn+9ni|_D z7mJ7Zaxdw_em}2dnbqqL2B)m~{+~Mxy2)6-{5=5sJwFtJ xAwR" + { 10, 11, { 2, 3, 3, 3 }}, // 0x3F "?" + { 10, 11, { 2, 3, 3, 3 }}, // 0x40 "@" + { 10, 11, { 2, 3, 3, 3 }}, // 0x41 "A" + { 10, 11, { 2, 3, 3, 3 }}, // 0x42 "B" + { 10, 11, { 2, 3, 3, 3 }}, // 0x43 "C" + { 10, 11, { 2, 3, 3, 3 }}, // 0x44 "D" + { 10, 11, { 2, 3, 3, 3 }}, // 0x45 "E" + { 10, 11, { 2, 3, 3, 3 }}, // 0x46 "F" + { 10, 11, { 2, 3, 3, 3 }}, // 0x47 "G" + { 10, 11, { 2, 3, 3, 3 }}, // 0x48 "H" + { 6, 11, { 2, 5, 3, 5 }}, // 0x49 "I" + { 7, 11, { 2, 5, 3, 4 }}, // 0x4A "J" + { 9, 11, { 2, 3, 3, 4 }}, // 0x4B "K" + { 8, 11, { 2, 4, 3, 4 }}, // 0x4C "L" + { 11, 11, { 2, 3, 3, 2 }}, // 0x4D "M" + { 10, 11, { 2, 3, 3, 3 }}, // 0x4E "N" + { 10, 11, { 2, 3, 3, 3 }}, // 0x4F "O" + { 10, 11, { 2, 3, 3, 3 }}, // 0x50 "P" + { 10, 11, { 2, 3, 3, 3 }}, // 0x51 "Q" + { 10, 11, { 2, 3, 3, 3 }}, // 0x52 "R" + { 10, 11, { 2, 3, 3, 3 }}, // 0x53 "S" + { 10, 11, { 2, 3, 3, 3 }}, // 0x54 "T" + { 10, 11, { 2, 3, 3, 3 }}, // 0x55 "U" + { 10, 11, { 2, 3, 3, 3 }}, // 0x56 "V" + { 11, 11, { 2, 3, 3, 2 }}, // 0x57 "W" + { 10, 11, { 2, 3, 3, 3 }}, // 0x58 "X" + { 10, 11, { 2, 3, 3, 3 }}, // 0x59 "Y" + { 10, 11, { 2, 3, 3, 3 }}, // 0x5A "Z" + { 6, 11, { 2, 5, 3, 5 }}, // 0x5B "[" + { 8, 11, { 2, 4, 3, 4 }}, // 0x5C "\" + { 6, 11, { 2, 5, 3, 5 }}, // 0x5D "]" + { 8, 7, { 2, 4, 7, 4 }}, // 0x5E "^" + { 10, 3, { 10, 3, 3, 3 }}, // 0x5F "_" + { 6, 5, { 8, 6, 3, 4 }}, // 0x60 "`" + { 8, 7, { 6, 4, 3, 4 }}, // 0x61 "a" + { 8, 11, { 2, 4, 3, 4 }}, // 0x62 "b" + { 8, 7, { 6, 4, 3, 4 }}, // 0x63 "c" + { 8, 11, { 2, 4, 3, 4 }}, // 0x64 "d" + { 8, 7, { 6, 4, 3, 4 }}, // 0x65 "e" + { 7, 11, { 2, 5, 3, 4 }}, // 0x66 "f" + { 8, 9, { 6, 4, 1, 4 }}, // 0x67 "g" + { 8, 11, { 2, 4, 3, 4 }}, // 0x68 "h" + { 6, 11, { 2, 5, 3, 5 }}, // 0x69 "i" + { 7, 13, { 2, 5, 1, 4 }}, // 0x6A "j" + { 8, 11, { 2, 4, 3, 4 }}, // 0x6B "k" + { 5, 11, { 2, 5, 3, 6 }}, // 0x6C "l" + { 10, 7, { 6, 2, 3, 2 }}, // 0x6D "m" + { 8, 7, { 6, 4, 3, 4 }}, // 0x6E "n" + { 8, 7, { 6, 4, 3, 4 }}, // 0x6F "o" + { 8, 9, { 6, 4, 1, 4 }}, // 0x70 "p" + { 8, 9, { 6, 4, 1, 4 }}, // 0x71 "q" + { 8, 7, { 6, 4, 3, 4 }}, // 0x72 "r" + { 8, 7, { 6, 4, 3, 4 }}, // 0x73 "s" + { 8, 9, { 4, 4, 3, 4 }}, // 0x74 "t" + { 8, 7, { 6, 4, 3, 4 }}, // 0x75 "u" + { 8, 7, { 6, 4, 3, 4 }}, // 0x76 "v" + { 9, 7, { 6, 4, 3, 3 }}, // 0x77 "w" + { 8, 7, { 6, 4, 3, 4 }}, // 0x78 "x" + { 8, 9, { 6, 4, 1, 4 }}, // 0x79 "y" + { 8, 7, { 6, 4, 3, 4 }}, // 0x7A "z" + { 7, 11, { 2, 5, 3, 4 }}, // 0x7B "{" + { 4, 11, { 2, 6, 3, 6 }}, // 0x7C "|" + { 7, 11, { 2, 4, 3, 5 }}, // 0x7D "}" + { 10, 5, { 5, 3, 6, 3 }}, // 0x7E "}" + { 0, 0, { 0, 0, 0, 0 }}, // 0x7F +}; diff --git a/src/util/gui/font-metrics.h b/src/util/gui/font-metrics.h new file mode 100644 index 000000000..6ea1542a5 --- /dev/null +++ b/src/util/gui/font-metrics.h @@ -0,0 +1,13 @@ +/* Copyright (c) 2013-2015 Jeffrey Pfau + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ +#ifndef DEFAULT_FONT_METRICS_H +#define DEFAULT_FONT_METRICS_H + +#include "util/gui/font.h" + +extern struct GUIFontGlyphMetric defaultFontMetrics[]; + +#endif diff --git a/src/util/gui/font.h b/src/util/gui/font.h index 4120814c2..3679687fe 100644 --- a/src/util/gui/font.h +++ b/src/util/gui/font.h @@ -18,6 +18,17 @@ enum GUITextAlignment { GUI_TEXT_RIGHT }; +struct GUIFontGlyphMetric { + int width; + int height; + struct { + int top; + int right; + int bottom; + int left; + } padding; +}; + int GUIFontHeight(const struct GUIFont*); void GUIFontPrintf(const struct GUIFont*, int x, int y, enum GUITextAlignment, uint32_t color, const char* text, ...);