forum.boolean.name

forum.boolean.name (http://forum.boolean.name/index.php)
-   2D-программирование (http://forum.boolean.name/forumdisplay.php?f=109)
-   -   Шрифты (http://forum.boolean.name/showthread.php?t=4872)

zheland 27.10.2007 20:58

Шрифты
 
Во первых проблемма:
Выводит текст маленького размера а я пишу "64":
Код:


gfx_fnt=LoadImageFont("FixedSys.ttf",64)
SetImageFont(gfx_fnt)
DrawText "Hello",400,0

Потом:Чем лучше '.ttf'
И еще:
В Blitz3D есть функция:
Код:

Text x,y,string$,[center x],[center y]
А в BlitzMax:
Код:

DrawText string$,x,y
Почему нету 2 параметров или есть другая функция функция

jimon 27.10.2007 22:20

Re: Шрифты
 
.ttf - TrueType Font http://en.wikipedia.org/wiki/TrueType

... посмотрел в исходники max2d.mod
Код:

Rem
bbdoc: Draw text
about:
#DrawText prints strings at position @x,@y of the graphics display using
the current image font specified by the #SetImageFont command.<br>
Other commands that affect #DrawText include #SetColor, #SetHandle,
#SetScale, #SetRotation, #SetOrigin, #SetViewPort, #SetBlend and #SetAlpha.<br>
It is recomended that the blend mode be set to ALPHABLEND using the #SetBlend
command for non jagged antialiased text. Text that will be drawn at a smaller
size using the #SetScale command should use fonts loaded with the SMOOTHFONT
style to benefit from mip-mapped filtering, see #LoadImageFont for more information.
End Rem
Function DrawText( t$,x#,y# )
        gc.image_font.Draw t,..
        x+gc.origin_x+gc.handle_x*gc.tform_ix+gc.handle_y*gc.tform_iy,..
        y+gc.origin_y+gc.handle_x*gc.tform_jx+gc.handle_y*gc.tform_jy,..
        gc.tform_ix,gc.tform_iy,gc.tform_jx,gc.tform_jy
End Function

Код:

        Method Draw( text$,x#,y#,ix#,iy#,jx#,jy# )

                For Local i=0 Until text.length
               
                        Local n=CharToGlyph( text[i] )
                        If n<0 Continue
                       
                        Local glyph:TImageGlyph=LoadGlyph(n)
                        Local image:TImage=glyph._image
                       
                        If image
                                Local frame:TImageFrame=image.Frame(0)
                                If frame
                                        Local tx#=glyph._x*ix+glyph._y*iy
                                        Local ty#=glyph._x*jx+glyph._y*jy                       
                                        frame.Draw 0,0,image.width,image.height,x+tx,y+ty
                                EndIf
                        EndIf
                       
                        x:+glyph._advance*ix
                        y:+glyph._advance*jx
                Next
               
        End Method

теоретически я вот что думаю ...
private в imagefont.bmx не стоит .. мона нагло выдрать его :)
написать ручками в своей проге свой типа DrawText2
там генерить ету картинку из типа фонта (получаем TImageGlyph)
ставим указатель по центру и рендерим картинку

в принципе не сложно если реально нужны такие заморочки
не легче пощитать смещение ? и отнять от вводимых координат
или ты не можеж на глаз определить размеры текста ? :)

ps. можеж вообще отредактировать max2d.mod как душа зажелает :)
а точнее строчку frame.Draw 0,0,image.width,image.height,x+tx,y+ty
там надо типа
frame.Draw 0,0,image.width,image.height,x+tx-center_x/2,y+ty-center_y/2
если конечно я не ошибаюсь ...

ps2. почему бы не пошаманить с SetOrigin и SetHandle ? ;)


Часовой пояс GMT +4, время: 20:02.

vBulletin® Version 3.6.5.
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Перевод: zCarot