Looking for tk internals information
Author |
Message |
lvir.. #1 / 17
|
Looking for tk internals information
I've a developer who wants to be able to locate what font is being used in a particular widget. He has a widget into which he inserts a stream of text from a file. Throughout the text, there will be various unicode characters. He wants to be able to request from Tk the name of the font being used for any particular 'character' in the widget. Now, it appears from my searching that there is no simple answer to this. So my question is - what is the hard answer? What could he write, in C if necessary, to dig out this info, or even to insert into the stream when the insert is taking place, to generate a trace of this information? As for why - there are several reasons. Let's take this one for example. User A runs the app, and sees the document just fine. User B runs the app, and sees the dreaded \u notation for one or more characters. It would be useful, in helping user b improve his/her environment, to know what font is being used, so that one makes certain the right things in the right order are getting initialized. -- <URL: http://www.*-*-*.com/ ; In God we trust. Even if explicitly stated to the contrary, nothing in this posting should be construed as representing my employer's opinions.
|
Tue, 05 Sep 2006 22:36:03 GMT |
|
|
Benjamin Riefenstah #2 / 17
|
Looking for tk internals information
Hi Larry, Quote:
> Now, it appears from my searching that there is no simple answer to > this. So my question is - what is the hard answer? What could he > write, in C if necessary, to dig out this info, or even to insert > into the stream when the insert is taking place, to generate a trace > of this information?
I answered a similar question lately at <http://groups.google.com/groups?selm=m3r7vr8rvr.fsf%40seneca.benny.tu...>. For platforms with Tk-based font fallback, some commands in the test package could help maybe. For platforms with system-based fallback, you need to use platform APIs. Quote: > As for why - there are several reasons. Let's take this one for > example. > User A runs the app, and sees the document just fine. > User B runs the app, and sees the dreaded \u notation for one or > more characters. > It would be useful, in helping user b improve his/her environment, > to know what font is being used, so that one makes certain the right > things in the right order are getting initialized.
The main thing here is that you need to have fonts installed for the characters in question, any font that has the characters should do. If there is a font and it's not found, than that's not a question of order of initialization, it's a bug. Or there may exist a limitation of the platform in some cases, that the specific font can not be used to its full potential, like in the current Mac OS X implementation or if the font is badly formatted. benny
|
Tue, 05 Sep 2006 23:05:48 GMT |
|
|
Bryan Oakle #3 / 17
|
Looking for tk internals information
Quote:
>>As for why - there are several reasons. Let's take this one for >>example. >>User A runs the app, and sees the document just fine. >>User B runs the app, and sees the dreaded \u notation for one or >>more characters. >>It would be useful, in helping user b improve his/her environment, >>to know what font is being used, so that one makes certain the right >>things in the right order are getting initialized. > The main thing here is that you need to have fonts installed for the > characters in question, any font that has the characters should do. > If there is a font and it's not found, than that's not a question of > order of initialization, it's a bug. Or there may exist a limitation > of the platform in some cases, that the specific font can not be used > to its full potential, like in the current Mac OS X implementation or > if the font is badly formatted.
I think the point is, the original poster has exactly this problem. User B has the "bug" that they don't have a proper font installed. User B then wants to ask user A "hey, what font do you have installed to display these weird characters" but there's no way for user A to definitely answer that question. The problem being, user A may say "use font X" but if font X doesn't have a particular character tk will find a font Y that does. I think the ability to say "what is the complete font spec used for char (or widget) X?" would be quite handy. Yes, I know about 'font actual' but it sometimes lies. Once a string is rendered on screen it'd be nice to determine exactly what font specification can be used to duplicate what is seen.
|
Tue, 05 Sep 2006 23:36:22 GMT |
|
|
Cameron Lai #4 / 17
|
Looking for tk internals information
. . . Quote: >I think the point is, the original poster has exactly this problem. User >B has the "bug" that they don't have a proper font installed. User B >then wants to ask user A "hey, what font do you have installed to >display these weird characters" but there's no way for user A to >definitely answer that question. The problem being, user A may say "use >font X" but if font X doesn't have a particular character tk will find a >font Y that does. >I think the ability to say "what is the complete font spec used for char >(or widget) X?" would be quite handy. Yes, I know about 'font actual' >but it sometimes lies. Once a string is rendered on screen it'd be nice >to determine exactly what font specification can be used to duplicate >what is seen.
Me, too. --
Business: http://www.Phaseit.net
|
Tue, 05 Sep 2006 23:56:37 GMT |
|
|
Donal K. Fellow #5 / 17
|
Looking for tk internals information
Quote:
> I think the ability to say "what is the complete font spec used for > char (or widget) X?" would be quite handy. Yes, I know about 'font > actual' but it sometimes lies. Once a string is rendered on screen > it'd be nice to determine exactly what font specification can be used > to duplicate what is seen.
Hmm. I think the right thing to do would be to add an extra option to [font actual] (perhaps called -character?) to allow the specification of exactly which character in the font to use. The default (empty) would give information about the master virtual font, and if a character was specified (actually it'd be a string, but internally we'd use the first char of the string) then we'd return information about the physical font used to implement that particular character. None of this currently exists, of course, but does it sound like a reasonable API for when that situation is rectified? Donal.
|
Wed, 06 Sep 2006 00:13:54 GMT |
|
|
Cameron Lai #6 / 17
|
Looking for tk internals information
Quote:
>> I think the ability to say "what is the complete font spec used for >> char (or widget) X?" would be quite handy. Yes, I know about 'font >> actual' but it sometimes lies. Once a string is rendered on screen >> it'd be nice to determine exactly what font specification can be used >> to duplicate what is seen. >Hmm. I think the right thing to do would be to add an extra option to >[font actual] (perhaps called -character?) to allow the specification of >exactly which character in the font to use. The default (empty) would >give information about the master virtual font, and if a character was >specified (actually it'd be a string, but internally we'd use the first >char of the string) then we'd return information about the physical font >used to implement that particular character. >None of this currently exists, of course, but does it sound like a >reasonable API for when that situation is rectified?
. . . So you *are* saying, "to allow the specification *and introspection* ...", right? --
Business: http://www.Phaseit.net
|
Wed, 06 Sep 2006 00:25:24 GMT |
|
|
Bryan Oakle #7 / 17
|
Looking for tk internals information
Quote:
>> I think the ability to say "what is the complete font spec used for >> char (or widget) X?" would be quite handy. Yes, I know about 'font >> actual' but it sometimes lies. Once a string is rendered on screen >> it'd be nice to determine exactly what font specification can be used >> to duplicate what is seen. > Hmm. I think the right thing to do would be to add an extra option to > [font actual] (perhaps called -character?) to allow the specification of > exactly which character in the font to use. The default (empty) would > give information about the master virtual font, and if a character was > specified (actually it'd be a string, but internally we'd use the first > char of the string) then we'd return information about the physical font > used to implement that particular character. > None of this currently exists, of course, but does it sound like a > reasonable API for when that situation is rectified?
I'm not sure if that would solve my particular problem or not. My problem has to do with the following code: label .l1 -text "Hello World" -font $somefontspec label .l2 -text "Hello World" -font [font actual $somefontspec] ... for certain values of $somefontspec, I'll get different fonts. For example, if $somefontspec is set to the font alias "6x13" I'll see this problem. This may be the same or related to tk bug 220849.
|
Wed, 06 Sep 2006 00:26:31 GMT |
|
|
Bruce Hartwe #8 / 17
|
Looking for tk internals information
Quote:
>> I think the ability to say "what is the complete font spec used for >> char (or widget) X?" would be quite handy. Yes, I know about 'font >> actual' but it sometimes lies. Once a string is rendered on screen >> it'd be nice to determine exactly what font specification can be used >> to duplicate what is seen. > Hmm. I think the right thing to do would be to add an extra option to > [font actual] (perhaps called -character?) to allow the specification of > exactly which character in the font to use. The default (empty) would > give information about the master virtual font, and if a character was > specified (actually it'd be a string, but internally we'd use the first > char of the string) then we'd return information about the physical font > used to implement that particular character. > None of this currently exists, of course, but does it sound like a > reasonable API for when that situation is rectified?
sounds like a reasonable way to go. And I agree this would be a good thing. Bruce
|
Wed, 06 Sep 2006 00:21:00 GMT |
|
|
lvir.. #9 / 17
|
Looking for tk internals information
:If there is a font and it's not found, than that's not a question of :order of initialization, it's a bug. I never thought of it as a Tk initialization situation - but desire some way to determine what font is missing. On a Unix file system, where one has multiple terabytes of data, locating what is missing in a user's environment is non-trivial. -- <URL: http://wiki.tcl.tk/ > In God we trust. Even if explicitly stated to the contrary, nothing in this posting should be construed as representing my employer's opinions.
|
Wed, 06 Sep 2006 01:03:40 GMT |
|
|
lvir.. #10 / 17
|
Looking for tk internals information
Anyone have an example of how to go about taking the contents of a text widget and writing it to paper, correctly reproducing the various characters from various fonts? -- <URL: http://wiki.tcl.tk/ > In God we trust. Even if explicitly stated to the contrary, nothing in this posting should be construed as representing my employer's opinions.
|
Wed, 06 Sep 2006 01:06:50 GMT |
|
|
Benjamin Riefenstah #11 / 17
|
Looking for tk internals information
Hi Bryan, Quote:
> My problem has to do with the following code: > label .l1 -text "Hello World" -font $somefontspec > label .l2 -text "Hello World" -font [font actual $somefontspec] > ... for certain values of $somefontspec, I'll get different > fonts. For example, if $somefontspec is set to the font alias "6x13" > I'll see this problem. > This may be the same or related to tk bug 220849.
Looks like a bug/limitation to me, but probably not that one. On my system "6x13" is an alias for a font with width=semicondensed. [font actual] expands the font alias correctly into individual attributes (more or less). But it seems that we don't have a "width" attribute in Tk's font spec system, so Tk can't correctly reassemble the font from those attributes again. I remember a discussion on allowing attributes like "expanded" and similar for fonts, but I am not aware of actual code for this. Try searching the tcl-core mailing list archives. benny
|
Thu, 07 Sep 2006 22:57:41 GMT |
|
|
Benjamin Riefenstah #12 / 17
|
Looking for tk internals information
Hi Bryan, all, Quote:
> Once a string is rendered on screen it'd be nice to determine > exactly what font specification can be used to duplicate what is > seen.
Several people have now said that they like that feature. It's certainly possible to implement something like this. I have a number of thoughts here from my experience in this area: Tk-based fallback: Systems with Tk-based fallback already have the information, it's just the question of exporting that information as an API and/or a Tcl command or sub-command. Traditional X11: I am not sure how Tk gets the information with traditional X11 rendering. If Tk relies on the charset indicator (the last two fields of the font spec string), than this is rather unreliable at least for Unicode fonts. There are lots of Unicode fonts, but none is really complete (nor should they be), so the charset field is misleading. Of course this would be a wider problem than just here. Xft: I don't understand how Xft does it. ATSU: ATSU can do this, actually I already have an implementation for my own use. ;-) UniScript: If we want at some point use UniScript on Windows (there are good reasons to want that at some point), we will have the problem that the UniScript doesn't give us this information for its built-in font fallback feature. So I am not sure that this can be more than a best-effort command. I don't think we should exclude a font rendering system just because it can't give us this information. OTOH we don't want to avoid this command on all platforms just because some "wierd" system that we don't even use right now, may not allow us to implement it. ;-) I am also not sure that we actually need this in the core. We would need a C-level API in the core for Tk-based font fallback. In general, I think this may be better packaged as an extension or even an external binary. OTOH if you want this as a diagnostic tool, you probably want it without downloading something, you want it built-in. Also, is this really the information we want? In that scenario that was given "I want to replicate the font specification from machine A on machine B", what happens, if you are not allowed to transfer the font file in question because of license limitations? Or because of differences in font support between the machines? Wouldn't it be an even better help to have a utility that can enumerate all fonts on your system that support some given character? Instead of just telling you what font you are actually using right now? That would at least give you some more options. And how do you determine the actual font file in the first place? All that Tk gives you right is the family name and other attributes, how do you know the font file from a specification like "-family fixed -size 7 -weight normal -slant roman"? benny
|
Thu, 07 Sep 2006 23:12:49 GMT |
|
|
lvir.. #13 / 17
|
Looking for tk internals information
:Also, is this really the information we want? In that scenario that :was given "I want to replicate the font specification from machine A :on machine B", what happens, if you are not allowed to transfer the :font file in question because of license limitations? Or because of :differences in font support between the machines? One puts in a request to one's admin to purchase another license. But right now, we can't even do that - because we have no idea what font to request. A company is unlikely to run out and purchase licenses for User B to match every font that User A has purchased - unless they are all required by the application. :Wouldn't it be an even better help to have a utility that can :enumerate all fonts on your system that support some given character? :Instead of just telling you what font you are actually using right :now? That would at least give you some more options. For my case, my developer needs to answer the question "what font do I need to purchase so a user can display character UUU", where said character is not known ahead of time (this isn't a value being shown in a label - but random characters appearing in contributed files from this point on to the future. So deciding an interface for how to feed character UUU to a utility seems less useful. The most frequent scenario is that one user gets some document, they can read all the characters, then a second user goes to read the document, and they can't. However, I can certain foresee, as time goes on, the scenario that the first user cannot read all the characters in a file, and then we are faced with 'where do we find a font that contains these characters'? :And how do you determine the actual font file in the first place? All :that Tk gives you right is the family name and other attributes, how :do you know the font file from a specification like "-family fixed :-size 7 -weight normal -slant roman"? Right now, we apparently can't at a script level. But if Tk is finding a font that displays the character, then a new interface to introspectively determine what font was selected seems the best solution. -- <URL: http://wiki.tcl.tk/ > In God we trust. Even if explicitly stated to the contrary, nothing in this posting should be construed as representing my employer's opinions.
|
Fri, 08 Sep 2006 20:05:00 GMT |
|
|
Page 1 of 2
|
[ 17 post ] |
|
Go to page:
[1]
[2] |
|