flat assembler
Message board for the users of flat assembler.
Index
> IDE Development > IDE font: Proportional or not? Goto page 1, 2 Next |
Author |
|
JohnFound 23 Oct 2012, 14:21
AsmGuru62 wrote: The proportional font is much easier to implement. This statement is pretty disputable. IMHO, mono spaced font is much easier to implement. Not for nothing most code editors use mono spaced fonts. Additionally, proportional fonts have problems with column alignment - what is essential for assembly programming. _________________ Tox ID: 48C0321ADDB2FE5F644BB5E3D58B0D58C35E5BCBC81D7CD333633FEDF1047914A534256478D9 |
|||
23 Oct 2012, 14:21 |
|
AsmGuru62 23 Oct 2012, 17:26
I do not understand.
When I say "proportional" - I mean, like "Courier". Is it same as mono spaced? |
|||
23 Oct 2012, 17:26 |
|
JohnFound 23 Oct 2012, 18:32
|
|||
23 Oct 2012, 18:32 |
|
uart777 23 Oct 2012, 19:25
Hi, Guru. Monospace means each character glyph/image is exactly the same size; example, 16x20. Monochrome means 1BPP binary, pure black (0) or white (0FFFFFFh), hard edges with no anti-aliasing. Menuet/Kolibri needs help with this. Here's my favorite programming font, code2, it's real easy to use:
[img] http://sungod777.zxq.net/CODE2.bmp [/img] And here's my old bitmap font definitions: Code: ; $$$$$$$$$$$$$$ Z77 ASM LIBRARY $$$$$$$$$$$$$$$$$ ; ************** SUNGOD SOFTWARE ***************** ; ?????????????????? FONT.INC ???????????????????? ; get.font f ; get current font ; set.font f ; set font style ; set.font.color c ; set font color ; set.font.c f, c ; set style and color ; load.font/s... ; load image/s to font/s ; load.all.fonts ; from /FONT/ to fonts array ; destroy.font f ; backup.font ; restore.font ; draw.c c, x, y ; draw 'c'haracter ; draw.text t, x, y ; draw 'text' ; draw.text.a t, a ; aligned in screen ; draw.text.align t, b, a ; or another box ; text.w/h get the exact size of single or ; multi-line text in the current font. example: ; if font.w=20, text.w('ABC') will return 60. ; text.width/height get the size of text with ; insets applied: font.w/2, font.h/4. ; make.text.box creates a box that is the size ; of text with insets ; text.w t ; text.h t ; text.width t ; text.height t ; make.text.box t, box ; draw.caption t, x, y ; draw.caption.x t, x, y, style, c, fc, lc ; draw.caption.a t, a ; draw.caption.align t, box, a ; set.colors c, fc, lc ; set.graphics g ; set.justify j ; backup.theme ; restore.theme STRUCTURE FONT ; custom bitmap font TEXT name(32) ; example: "Console" NUMBER type ; 0 for monospace raster NUMBER w, h ; glyph size. example: 16x24 COLOR color ; if type&FT_RASTER IMAGE image ; glyph images ENDS ASSUME ?font=FONT powers FT_MONOSPACE, FT_VARIABLE, FT_RASTER,\ FT_IMAGE, FT_TEXTURE, FT_GRADIENT, FT_ALPHA numeric FT_DEFAULT=FT_MONOSPACE+FT_RASTER align 4 FONT font, font.backup TEXT font.folder='FONT\',\ font.ext='.BMP', font.wild='*.BMP' ;;;;;;;;;;;;;;;;;;; SYMBOLS ;;;;;;;;;;;;;;;;;;;;;; ; my default character arrangement: 95 symbols. ; includes all standard visible characters ; 0 1 2 3 4 5 6 7 8 9 A B C D E F G H I ; J K L M N O P Q R S T U V W X Y Z a b ; c d e f g h i j k l m n o p q r s t u ; v w x y z _ . ? ; : ' " , ~ ! @ # $ ; % ^ & * ( ) [ ] { } = + - < > / \ | ` ; symbol lookup table to convert 7BIT ASCII ; character to index. 63=ignore (spaces, etc) N_SYMBOLS=95 FONT_SYMBOLS: db \ 63,63,63,63,63,63,63,63, 63,63,63,63,63,63,63,63,\ 63,63,63,63,63,63,63,63, 63,63,63,63,63,63,63,63,\ 63,72,69,74,75,76,78,68, 80,81,79,87,70,88,64,91,\ 00,01,02,03,04,05,06,07, 08,09,67,66,89,86,90,65,\ 73,10,11,12,13,14,15,16, 17,18,19,20,21,22,23,24,\ 25,26,27,28,29,30,31,32, 33,34,35,82,92,83,77,62,\ 94,36,37,38,39,40,41,42, 43,44,45,46,47,48,49,50,\ 51,52,53,54,55,56,57,58, 59,60,61,84,93,85,71,63 ;;;;;;;;;;;;;;; GET/SET FONT/COLOR ;;;;;;;;;;;;;;; command get.font, f memory.copy [f], font, FONT.$ endc command set.font, f push [font.color] memory.copy font, [f], FONT.$ pop [font.color] endc command set.font.c, f, c memory.copy font, [f], FONT.$ let [font.color]=[c] endc macro set.font.color c { let [font.color]=c } command destroy.font, f let eax=[f] destroy [?font.image.p+eax] endc macro backup.font { get.font font.backup } macro restore.font { set.font font.backup } ;;;;;;;;;;;;;;; LOAD BITMAP FONT ;;;;;;;;;;;;;;;;; ; font.w=image.w/N_SYMBOLS, font.h=image.h (same) command load.font, font, file locals name, image, w, h let eax=[font],\ ecx=&[?font.name+eax], [name]=ecx,\ ecx=&[?font.image+eax], [image]=ecx text.copy [name], [file] remove.ext [name] text.uppercase [name] !if load.image, [image], [file] ; returns w/h let [w]=ecx, [h]=edx, eax=ecx,\ ; in ecx/edx ecx=N_SYMBOLS, eax/ecx, ecx=[font],\ [?font.w+ecx]=eax, [?font.h+ecx]=[h] set.image.key [image] .end set.font.c [font], WHITE endc ; load fonts by name macro load.fonts [p] { forward make.txt eax, 'FONT\'#`p#'.BMP' load.font p#.f, eax } ;;;;;;;;;;;;;;;;;; SYSTEM FONTS ;;;;;;;;;;;;;;;;;; macro define.system.fonts { FONT text.f, text2.f,\ code1.f, code2.f, code3.f, code4.f, code5.f, console.f, console2.f,\ type.f, type2.f } macro load.system.fonts { load.fonts text, text2,\ code1, code2, code3, code4, code5, console, console2,\ type, type2 } ;;;;;;;;;;;;;;;;;; FONT ARRAY ;;;;;;;;;;;;;;;;;;;; align 8 ARRAY fonts(FONT.$), font.files(1*KB) NUMBER font.index ; create dynamic array of FONT structures then ; load all fonts from \FONT\. this may be ; located in the current directory or 1-2 higher ; directories for all projects to share command load.all.fonts locals i, p where.is font.folder ; get filenames fail .r find.files font.files, font.wild .loop [i]=0 to [font.files.n] ; load images get [p]=array.index font.files, [i] array.expand fonts load.font eax, [p] .endl let eax=[fonts] .r: let [font.index]=0 endc ; set.font i - set current font by index command set.font.i, i array.index fonts, [i] set.font eax let [font.index]=[i] endc ; get font name by index command get.font.name, i array.index fonts, [i] let eax=&[?font.name+eax] endc ; get font index by name or return -1 ; if doesn't exist command get.font.i, name locals i .loop [i]=0 to [fonts.n] array.index fonts, [i] let eax=&[?font.name+eax] .if.text.equal name, eax return [i] .end .endl let eax=-1 endc command destroy.fonts locals i .loop [i]=0 to [fonts.n] array.index fonts, [i] destroy.font eax .endl endc ;;;;;;;;;;;;;;;;; DRAW CHARACTER ;;;;;;;;;;;;;;;;; ; the heart of all draw text functions ; draw.c 'Z', 1, 1 command draw.c, ch, x, y locals p, iw, i, n let eax=FONT_SYMBOLS, eax+[ch] cmp byte [eax], 63 ; invisible? je .r visible [x], [y], [font.w], [font.h] fail .r ; p=&image[symbols[ch]*font.w*4] let eax=FONT_SYMBOLS, eax+[ch],\ eax=>[eax], eax*[font.w], eax<<2,\ eax+[font.image.p], [p]=eax,\ [iw]=[font.image.w], [iw]<<2 ; draw font.h # scanlines .loop [i]=0 to [font.h] let ecx=[y], ecx+[i] draw.scanline.v [p], [x], ecx,\ [font.w], [font.color] let ecx=[p], ecx+[iw], [p]=ecx .endl let eax=[draw.c.p] .r: endc ; current draw character function pointer. ; just redefine this for custom gradients ; and textures align 8 VOID draw.c.p=!draw.c command set.draw.c, a let [draw.c.p]=[a] endc ;;;;;;;;;;;;;;;;;;; DRAW TEXT ;;;;;;;;;;;;;;;;;;;; ; draw.text.t 'SunGod Software', 1, 1 command draw.text, t, x, y locals i, n, p let eax=[t],\ [p]=eax, [i]=0 .while byte [eax] ; draw all characters let ecx=[i],\ ; x=i*font.w+x ecx*[font.w],\ ecx+[x] let eax=[p],\ ; get c eax=>[eax] .if eax=0Dh ; return? let [i]=0,\ ; reset x ecx=[font.h],\ [y]+ecx, [p]++,\ ; y+font.h [i]=0 jmp .next .end let edx=[y],\ ; get y+font.h edx-[font.h] cmp edx, [screen.h] ; off screen? jg .r ; return calla [draw.c.p],\ ; draw character eax, ecx, [y] let [i]++ .next: let [p]++, eax=[p] ; eax=p for while .endw .r: endc ; literal 'text' version macro draw.text.t t, x, y { make.txt eax, t draw.text eax, x, y } ; set color then draw text macro draw.text.c t, x, y, c { set.font.color c draw.text t, x, y } ;;;;;;;;;;;;;;;;; TEXT/BOX SIZE ;;;;;;;;;;;;;;;;;; ; get width of 'text' in characters. if single ; line, w = text length. if multi-line, w = ; longest line command text.wc, t locals p, s, n, gw let [p]=[t], eax=[t] .if byte [eax]=0 ; no text return 0 .end ; which line has the greatest width? let [gw]=0 .line: ; get line let [s]=[p] get [p]=\ ; find first/next 0Dh text.find [p], 0Dh .if true ; multi-line? let eax-[s],\ ; length [n]=eax, [p]+2 .else ; single or last line? get [n]=text.n [s] ; length = until 0 .end let ecx=[n] .if ecx>[gw] ; greatest width? let [gw]=ecx .end .if [p] ; more lines? jmp .line .end let eax=[gw] .r: endc ; get height in characters or # lines command text.hc, t locals n, p let [n]=0,\ eax=[t], [p]=eax .if not byte [eax] ; no lines let eax=0 jmp .r .end .while [p] let [n]++ ; 1+ lines get [p]=text.find\ [p], 0Dh .if true let [p]+2 .end .endw let eax=[n] .r: endc ; get exact size in pixels of single or ; multi-line 'text' in current font. ; w=longest.line*font.w. h=n.lines*font.h command text.w, t text.wc [t] let eax*[font.w] endc command text.h, t text.hc [t] let eax*[font.h] endc ; return exact size in memory variables. ; w/h are sent by reference command text.size, t, w, h text.w [t] push eax text.h [t] pop ecx let edx=[w], [edx]=ecx,\ edx=[h], [edx]=eax endc ; get text insets: font.w/2, font.h/4 command text.ix let eax=[font.w], eax>>1 endc command text.iy let eax=[font.h], eax>>2 endc ; return insets in memory variables. x/y are ; sent by reference command text.insets, x, y text.ix let ecx=[x], [ecx]=eax text.iy let ecx=[y], [ecx]=eax endc ; get size of 'text' with insets applied: ; w*font.w+(inset.x*2), h*font.h+(inset.y*2) command text.width, t text.wc [t] let ecx=[font.w], eax*ecx, eax+ecx endc command text.height, t text.hc [t] let ecx=[font.h], eax*ecx, ecx>>1, eax+ecx endc ; return box size in memory variables. ; w/h are sent by reference command text.box.size, t, w, h text.width [t] push eax text.height [t] pop ecx let edx=[w], [edx]=ecx,\ edx=[h], [edx]=eax endc ; create box to contain text with insets. ; used by draw.caption/x and controls command make.text.box, t, box text.width [t] push eax text.height [t] pop ecx let edx=[box],\ [?box.w+edx]=ecx, [?box.h+edx]=eax endc ; create box based on width in characters command make.text.box.w, box, w let eax=[box],\ ecx=[w], edx=[font.w], ecx*edx, ecx+edx,\ [?box.w+eax]=ecx,\ ecx=[h], edx=[font.h], ecx*edx, edx>>1,\ ecx+edx, [?box.h+eax]=ecx endc ; text is considered "multi-line" if ; it contains at least one 0Dh, 2+ lines. ; any beginning or ending returns should be ; removed in non-editable graphic text macro is.multi.line t { text.find t, 0Dh } ;;;;;;;;;;; DRAW C/TEXT WITH ALIGNMENT ;;;;;;;;;;; ; draw c/text aligned inside of BOX (x/y/w/h). ; see BOX.INC alignment values: CENTER_X/Y, ; ALIGN_C/L/T/R/B/N/NE/E/SE/S/SW/W/NW, JUSTIFY_L/R BOX c.box, t.box command draw.c.align, c, b, a make.box c.box, [font.w], [font.h] align.box c.box, [b], [a] draw.c [c], [c.box.x], [c.box.y] endc command draw.text.align, t, b, a text.size [t], t.box.w, t.box.h align.box t.box, [b], [a] draw.text [t], [t.box.x], [t.box.y] endc command draw.text.in, t, b, a, nx, ny text.size [t], t.box.w, t.box.h align.box t.box, [b], [a] nudge.box t.box, [nx], [ny] draw.text [t], [t.box.x], [t.box.y] endc macro draw.text.align.t t, b, a { make.txt eax, t draw.text.align eax, b, a } macro draw.text.center t, b { draw.text.align t, b, CENTER } ;;;;;;;;;;;;;;;;;;;;; THEME ;;;;;;;;;;;;;;;;;;;;;; macro THEME.X { NUMBER graphics ; G_x style FONT font COLOR color,\ line.color,\ shade.color NUMBER justify } STRUCTURE THEME THEME.X ENDS ASSUME ?theme=THEME align 4 THEME theme, theme.backup macro set.colors c, fc, lc { let [theme.color]=c, [theme.font.color]=fc,\ [theme.line.color]=lc } macro set.default.colors { set.colors BLACK, WHITE, GRAY } macro set.graphics g { let [theme.graphics]=g } macro set.justify j { let [theme.justify]=j } command backup.theme memory.copy theme.backup, theme, THEME.$ let eax=theme, ecx=theme.backup endc command restore.theme memory.copy theme, theme.backup, THEME.$ endc ;;;;;;;;;;;;;;;;;;;; CAPTION ;;;;;;;;;;;;;;;;;;;;; ; "[Caption]"; a box/frame that contains text ; with insets and is drawn according to the ; current "theme" align 4 BOX ca.box, ct.box NUMBER _caption.w, _caption.h ; if G_STATIC command set.caption.size, w, h let [_caption.w]=[w], [_caption.h]=[h] endc command draw.caption, t, x, y locals i, n, p,\ w, h, ix, iy, graphics, justify let [graphics]=[theme.graphics],\ [justify]=[theme.justify] .if not [graphics] ; default if 0 set.graphics (G_DYNAMIC+G_COLOR+G_LINE+G_TEXT) let [graphics]=[theme.graphics] let eax=[theme.color] .if [theme.font.color]=eax ; default if same set.default.colors .end .end .if not [theme.justify] set.justify CENTER let [justify]=[theme.justify] .end .if [graphics]&G_STATIC ; get box size let [w]=[_caption.w], [h]=[_caption.h] .else.if [graphics]&G_DYNAMIC let eax=&[w], ecx=&[h] text.box.size [t], eax, ecx .end .if [graphics]&G_COLOR ; draw box? draw.box [x], [y], [w], [h],\ [theme.color], YES .end .if [graphics]&G_LINE ; outline? draw.box [x], [y], [w], [h],\ [theme.line.color], NO .end .if.n [graphics]&G_TEXT ; text? jmp .r ; no? return .end let eax=&[ix], edx=&[iy] ; size of text+insets text.insets eax, edx create.box ca.box, [x], [y], [w], [h] create.box.inside ct.box, ca.box, [ix], [iy] set.font.color [theme.font.color] get [n]=text.hc [t] let [p]=[t] .loop [i]=0 to [n] ; draw each row let eax=[p], edx=[?t] ; copy until return @@: let ecx=>[eax] test ecx, ecx jz @f cmp ecx, 0Dh je @f let cl=[eax], [edx]=cl, eax++, edx++ jmp @b @@: let eax+2, [p]=eax, byte [edx]=0 create.box ca.box, [ct.box.x], [ct.box.y],\ [ct.box.w], [font.h] let eax=[font.h], [ct.box.y]+eax,\ ; move down eax=[ca.box.x], ecx=[ca.box.y] draw.text.align [?t], ca.box, [justify] .endl .r: endc ; draw "[Caption]" in specified style and colors command draw.caption.x, t, x, y, style, c, fc, lc .if not [style] ; default let [style]=(G_DYNAMIC+G_COLOR+G_LINE+G_TEXT) .end set.graphics [style] set.colors [c], [fc], [lc] draw.caption [t], [x], [y] endc ; draw "[Caption]" aligned relative to ; the screen command draw.caption.a, t, a make.text.box [t], ca.box align.b ca.box, [a] draw.caption [t], [ca.box.x], [ca.box.y] endc ; draw "[Caption]" aligned inside of ; another box with optional nudge x/y command draw.caption.align, t, b, a make.text.box [t], ca.box align.box ca.box, [b], [a] draw.caption [t], [ca.box.x], [ca.box.y] endc command draw.caption.in, t, b, a, nx, ny make.text.box [t], ca.box align.box ca.box, [b], [a] nudge.box ca.box, [nx], [ny] draw.caption [t], [ca.box.x], [ca.box.y] endc |
|||
23 Oct 2012, 19:25 |
|
farrier 23 Oct 2012, 20:36
I am trying a different Monospace font, and after I got used to the appearance of the lower case l--el--character, I've decided I like it!
http://sourceforge.net/projects/sourcecodepro.adobe/ You have to get past the idea that it comes from Adobe! farrier _________________ Some Assembly Required It's a good day to code! U.S.Constitution; Bill of Rights; Amendment 1: ... the right of the people peaceably to assemble, ... The code is dark, and full of errors! |
|||
23 Oct 2012, 20:36 |
|
JohnFound 23 Oct 2012, 20:51
I always liked fixedsys excelsior font. It is Unicode and supports most of the languages. Also, it is perfect without anti aliasing. I always considering anti aliasing is very bad for the eyes.
http://www.fixedsysexcelsior.com/ |
|||
23 Oct 2012, 20:51 |
|
uart777 24 Oct 2012, 01:01
JohnFound: Yeah, FixedSys was a nice font in the days of DOS, although a bit small and not for higher resolutions (beyond VGA, 640x480). As an artist who creates fonts (PaintShop pro is my favorite), I would say Consolas is the best standard font for programming and it's vector-based and resizable dynamically (unlike Courier, Terminal, Lucida, etc). Anti-aliasing is not always bad, it just depends on how you do it. A little is good but not too much. code2 is intended for XGA-HD and it has a slight soft edge:
Last edited by uart777 on 24 Oct 2012, 02:00; edited 2 times in total |
|||
24 Oct 2012, 01:01 |
|
uart777 24 Oct 2012, 01:40
Here's a tutorial I wrote just for fun, "The ABCs of Raster Fonts", but never released until now...
I've created many tutorials like this just for personal reference but never shown anyone. Should I? |
|||
24 Oct 2012, 01:40 |
|
revolution 24 Oct 2012, 04:44
IMO for assembly source code there is a place for proportional fonts; in the comments following the semicolon. But for the main code I think that monospaced fonts are the best.
Code: label: opcode reg1,reg2 ;proportional spaced font only to be put after the semicolon |
|||
24 Oct 2012, 04:44 |
|
uart777 24 Oct 2012, 12:23
revolution: I agree with your statements, but only if IDEs can display it properly.
Last edited by uart777 on 29 Oct 2012, 02:44; edited 2 times in total |
|||
24 Oct 2012, 12:23 |
|
revolution 24 Oct 2012, 12:38
uart777 wrote: I'm claiming that my CODE2 is the best font for programming in higher resolutions (XGA+): For me that font sample you posted looks blurry and out of focus. So perhaps my display is much different from yours. |
|||
24 Oct 2012, 12:38 |
|
uart777 24 Oct 2012, 12:44
revolution: Wow, you're fast! Yes, what we say is all relative to our perspective. Just edited last post and I complimented you. Prove me wrong, show me better
Thanks so much for challenging me You separate the men from the boys |
|||
24 Oct 2012, 12:44 |
|
revolution 24 Oct 2012, 12:53
uart777 wrote: revolution: ... You're a smart man. Last edited by revolution on 24 Oct 2012, 12:54; edited 1 time in total |
|||
24 Oct 2012, 12:53 |
|
uart777 24 Oct 2012, 12:54
revolution: High-resolution means beyond S/VGA (640x480/800x600). Why disrespect my font and not show better? Why knock something down and replace it with nothing?
|
|||
24 Oct 2012, 12:54 |
|
revolution 24 Oct 2012, 12:55
uart777 wrote: revolution: High-resolution means beyond S/VGA (640x480/800x600). Why disrespect my font and not show better? Why knock something down and replace it with nothing? |
|||
24 Oct 2012, 12:55 |
|
uart777 24 Oct 2012, 12:59
revolution: You're absolutely correct. We all speak from our own perspective. I'm typing on a 720P HDTV. I just wish you would show me better than CODE2, but you can't
Last edited by uart777 on 24 Oct 2012, 16:04; edited 2 times in total |
|||
24 Oct 2012, 12:59 |
|
revolution 24 Oct 2012, 13:03
uart777 wrote: I just wish you would show me better than CODE2, but you can't |
|||
24 Oct 2012, 13:03 |
|
uart777 24 Oct 2012, 13:08
revolution: Ok, good luck with your programming. You can't show me better. How dare you disrespect my font without replacing it? Everything is subjective/relative to our perspective. Show me what you think is better.
PS: I complimented you in last reply. Thanks for caring. |
|||
24 Oct 2012, 13:08 |
|
revolution 24 Oct 2012, 13:19
uart777 wrote: How dare you disrespect my font without replacing it? |
|||
24 Oct 2012, 13:19 |
|
Goto page 1, 2 Next < Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.