Share

Tk Toolkit

Tracker: Patches

9 TIP 145: Font handling enhancements - ID: 780617
Last Update: Settings changed ( dkf )

This is the implementation for TIP 145: Enhanced Tk
Font handling.


Pat Thoyts ( patthoyts ) - 2003-07-31 00:57

9

Open

Remind

Pat Thoyts

47. Win Fonts

TIP Implementation

Public


Comments ( 18 )

Date: 2009-12-10 15:38
Sender: dgpProject Admin

status ?


Date: 2009-02-10 16:22
Sender: dkf

Taken private; hopefully this will do something to stem the spam...


Date: 2008-05-14 00:57
Sender: patthoyts


This patch is the final part of TIP #145

Tk_CreateNamedFont is placed in the public stubs.
Tk_FontAttributes is placed in tk.h

Now that the font attributes are exposed I want to declare a more general
set of font weight values that are more in keeping with the commonly
available font systems. Pango and Win32 both use the same set of symbolic
names and values in the range 0-1000.
Xft uses a similar set of names but in a range 0-255
XLFD has similar names but they are symbolic.

This extends the possible values of the weight field in font attributes
to
include normal, bold, light, ultralight, ultrabold and heavy

File Added: tip145-final-c.patch


Date: 2007-10-24 16:28
Sender: das


Joe,

those docs are wrong, OSX uses lucida 14 in menus. I changed fonts.tcl to
match what is returned by the GetThemeFont() API (which is what is now
actually used by HEAD to setup the Tk* fonts, c.f. tkMacOSXFont.c):

% foreach f [lsort [font names]] {puts "[format %-34s $f][font configure
$f]"}
TkCaptionFont -family {Lucida Grande} -size 13 -weight
bold -slant roman -underline 0 -overstrike 0

TkDefaultFont -family {Lucida Grande} -size 13 -weight
normal -slant roman -underline 0 -overstrike 0

TkFixedFont -family monaco -size 9 -weight normal
-slant roman -underline 0 -overstrike 0

TkHeadingFont -family {Lucida Grande} -size 11 -weight
normal -slant roman -underline 0 -overstrike 0

TkIconFont -family {Lucida Grande} -size 13 -weight
normal -slant roman -underline 0 -overstrike 0

TkMenuFont -family {Lucida Grande} -size 14 -weight
normal -slant roman -underline 0 -overstrike 0

TkSmallCaptionFont -family {Lucida Grande} -size 10 -weight
normal -slant roman -underline 0 -overstrike 0

TkTextFont -family {Lucida Grande} -size 13 -weight
normal -slant roman -underline 0 -overstrike 0

TkTooltipFont -family {Lucida Grande} -size 11 -weight
normal -slant roman -underline 0 -overstrike 0

systemAlertHeaderFont -family {Lucida Grande} -size 13 -weight
bold -slant roman -underline 0 -overstrike 0

systemApplicationFont -family {Lucida Grande} -size 13 -weight
normal -slant roman -underline 0 -overstrike 0

systemDetailEmphasizedSystemFont -family {Lucida Grande} -size 9 -weight
bold -slant roman -underline 0 -overstrike 0

systemDetailSystemFont -family {Lucida Grande} -size 9 -weight
normal -slant roman -underline 0 -overstrike 0

systemEmphasizedSystemFont -family {Lucida Grande} -size 13 -weight
bold -slant roman -underline 0 -overstrike 0

systemLabelFont -family {Lucida Grande} -size 10 -weight
normal -slant roman -underline 0 -overstrike 0

systemMenuItemCmdKeyFont -family {Lucida Grande} -size 14 -weight
normal -slant roman -underline 0 -overstrike 0

systemMenuItemFont -family {Lucida Grande} -size 14 -weight
normal -slant roman -underline 0 -overstrike 0

systemMenuItemMarkFont -family {Lucida Grande} -size 14 -weight
normal -slant roman -underline 0 -overstrike 0

systemMenuTitleFont -family {Lucida Grande} -size 14 -weight
normal -slant roman -underline 0 -overstrike 0

systemMiniSystemFont -family {Lucida Grande} -size 9 -weight
normal -slant roman -underline 0 -overstrike 0

systemPushButtonFont -family {Lucida Grande} -size 13 -weight
normal -slant roman -underline 0 -overstrike 0

systemSmallEmphasizedSystemFont -family {Lucida Grande} -size 11 -weight
bold -slant roman -underline 0 -overstrike 0

systemSmallSystemFont -family {Lucida Grande} -size 11 -weight
normal -slant roman -underline 0 -overstrike 0

systemSystemFont -family {Lucida Grande} -size 13 -weight
normal -slant roman -underline 0 -overstrike 0

systemToolbarFont -family {Lucida Grande} -size 11 -weight
normal -slant roman -underline 0 -overstrike 0

systemUtilityWindowTitleFont -family {Lucida Grande} -size 11 -weight
normal -slant roman -underline 0 -overstrike 0

systemViewsFont -family {Lucida Grande} -size 12 -weight
normal -slant roman -underline 0 -overstrike 0

systemWindowTitleFont -family {Lucida Grande} -size 13 -weight
normal -slant roman -underline 0 -overstrike 0




Date: 2007-10-24 16:09
Sender: jenglish


das -- fonts.tcl r1.7 has:

switch -- [tk windowingsystem] {
...
aqua {
...
set F(menusize) 14
...
font configure TkMenuFont -family $F(family) -size
$F(menusize)
}
}

But according to <URL:
http://developer.apple.com/documentation/UserExperience/Conceptual/OSXHIGuidelines/
>, Part III, section "Text", subsection "Fonts": "The system font (Lucida
Grande Regular 13 point) is used *for text in menus*, dialogs, and
full-size controls." Shouldn't $F(menusize) be the same as $F(size) (==
system font point size == 13)?






Date: 2007-10-23 09:18
Sender: patthoyts


I misread the handling of the faPtr arg in TkCreateNamedFont and thought
that the pointer was being copied into the NamedFont structure.
I've applied the suggested fixes - thanks das.


Date: 2007-10-21 20:13
Sender: dkf


General Note: When thinking about ckalloc() vs. stack "allocation",
consider whether to use TclStackAlloc() or thread-local allocation instead.
Since stack alloc is on the cards, TclStackAlloc()/TclStackFree() should
also work if an interp handle is available (needs tclInt.h for declaration
though).


Date: 2007-10-21 15:28
Sender: das


I have just committed TIP145 font name registration for the aqua theme
fonts to tkMacOSXFont.c

While looking at the windows implementation of this, I found what appear
to be bugs in tkWinFont.c's CreateNamedSystemFont():
- faPtr is leaked; in fact the whole allocation and copying of
TkFontAttributes is unnecessary, as TkCreateNamedFont() copies the
attributes again anyway.
- TkDeleteNamedFont() should be called with a NULL interp (just added
support for that), you don't want error info from it in the interp result.
- the allocation and freeing of a WinFont seems unnecessary and could be
replaced with a WinFont struct on the stack.



Date: 2006-12-22 11:51
Sender: dkf


Also, don't forget to leave a compatability typedef in tkFont.h, just in
case people are using that.


Date: 2006-12-22 11:50
Sender: dkf


Also need to rename type TkFontAttributes to Tk_FontAttributes and to move
it (together with defines of TK_FW_NORMAL, TK_FW_BOLD, TK_FS_ROMAN,
TK_FS_ITALIC, TK_FS_OBLIQUE) to tk.h from tkFont.h, and also need to add
documentation of the font names. This can either be a new manual page or an
addition to the font.n page.

Need to add TkHeadingFont and TkTextFont to the TIP. (Requires editor
assistance: contact me directly with the descriptions of the purpose of
these fonts, or add them to the comments in this tracker item.)


Date: 2006-12-22 10:16
Sender: patthoyts


Merging TIP #145 and the Tile font names I've updated the set in Windows
to TkDefaultFont, TkHeadingFont, TkTextFont, TkMenuFont, TkTooltipFont,
TkCaptionFont, TkSmallCaptionFont, TkIconFont and TkFixedFont.
A look over the TIP shows that this implementation needs to put the
TkCreateNamedFont function into the public stubs table as
Tk_CreateNamedFont which has yet to be done.
Attaching a new patch.
File Added: tkfont-20061222.patch


Date: 2006-12-20 16:13
Sender: patthoyts


Just need to agree names for the fonts. IIRC jenglish has some suggestions
deriving from the tile work. Tile provides
TkDefaultFont general gui font
TkTextFont user text, entries etc
TkHeadingFont column headings in table
TkCaptionFont dialog captions
TkTooltipFont tooltips
and I think I had the following listed in the TIP (probably mostly from
Windows stuff):
TkFixedFont fixed width font
TkMenuFont menu text
TkSmallCaptionFont captions on tool windows and contained dialogs, MDI
windows
TkIconFont icon captions (eg: MDI iconified things)


Date: 2006-12-08 06:38
Sender: hobbsSourceForge.net SubscriberProject Admin


We just need to standardize on a set of font names (TkXXXXXX), otherwise
its all just waiting in the wings.


Date: 2006-12-08 02:55
Sender: das


I'm currently revising tkMacOSXFont.c's TkpGetNativeFont() because I need
an additional standard OS font for menu items.
If this patch were in, I could use TkCreateNamedFont() instead (and would
at the same time implement the other system fonts defined in the TIP for
Aqua).
What's the status of this patch, any reason for the holdup since 2004?
this TIP has been flagged as one needing to be prioritized for 8.5...


Date: 2004-09-02 12:07
Sender: dkf

Logged In: YES
user_id=79902

I'm unsure about the technical content of the patch, but it
appears to be missing documentation and tests...


Date: 2004-09-01 12:15
Sender: vincentdarley

Logged In: YES
user_id=32170

Is this patch ready for committing to Tk? Given the vote
has passed, we ought to try to get this in soon...



Date: 2004-06-15 02:18
Sender: jenglish

Logged In: YES
user_id=68433

TIP #145 doesn't seem to provide an appropriate symbolic
font name for entry widgets.

Although on Windows Tk uses a single font for just about
everything (CTL_FONT == TkDefaultFont), on X11 it uses a
different font for entry widgets and canvas text items
(Helvetica -12) than it does for everything else (Helvetica
-12 bold). MacOSX is similar.

Text widgets also use a different default font on X11
(Courier -12). For those we can use TkFixedFont, but none
of the other symbolic names listed in the TIP seem to be
appropriate for entry widgets. Perhaps "TkTextFont" should
be added?


Date: 2004-01-31 23:40
Sender: patthoyts

Logged In: YES
user_id=202636

Uploaded a newer version


Attached Files ( 4 )

Filename Description Download
tk-font.patch Improved implementation Download
font.patch initial patch version Download
tkfont-20061222.patch Updated TIP #145 implementation Download
tip145-final-c.patch stubs change + multiple weights (unix patch) Download

Changes ( 10 )

Field Old Value Date By
resolution_id None 2010-01-17 17:05 dkf
is_private 1 2009-07-29 10:21 dkf
is_private 2009-02-10 16:22 dkf
File Added 277712: tip145-final-c.patch 2008-05-14 00:57 patthoyts
File Added 208251: tkfont-20061222.patch 2006-12-22 10:16 patthoyts
priority 5 2004-05-12 13:38 dkf
File Added 75342: tk-font.patch 2004-01-31 23:40 patthoyts
artifact_group_id None 2003-11-12 20:14 dkf
assigned_to hobbs 2003-08-13 14:57 patthoyts
File Added 57370: font.patch 2003-07-31 00:57 patthoyts