roland@ttds.UUCP (Roland Karlsson) (10/15/85)
This is a program that displays fonts. Features: 1. Always look at current system fonts. 2. Open files that contains fonts. 3. Write sample text with key board. 4. Write sample text with mouse. 5. Copy sample text to desc scrap (for later pasting in MacWrite). This posting is not only a distribution of my program. It is also a request for HELP. There are some things that i don't manages to do right. Therefore i will send three postings. 1. Source code in SUMacC. 2. hqx code. 3. HELP. This is: HELP !!!!! ============================================================================== Many thanks in advance: Roland Karlsson (roland@ttds) Dpt. of Telecomm. & Computer Systems Royal Institute of Technology S-100 44 Stockholm SWEDEN ============================================================================== I have 3 questions: 1. Scaling of fonts: 2. Reading desc scrap. 3. Filter for SFGetFile. ============================================================================== QUESTION 1. In the program i wan't to change Font Size. The problem is that, as far as i can see, you have to know the ascent of the new size. I can't find it anywhere. A working (:-) but not good solution is this. But how should i do? TEHandle h_text; change_font (size, font_name) int size, char *font_name; int font; ... GetFNum(font_name, &font) (*h_text)->fontAscent = (size * 3) / 4; /* How do this right ? */ (*h_text)->lineHeight = (*h_text)->txSize = size; (*h_text)->txFont = font; TECalText (h_text); ... } ============================================================================== ============================================================================== QUESTION 2. How to read from the desc scrap? I have made a working sub routine (put_scrap) which writes to the desc scrap but how to read from the desc scrap. This is how it looks in my program. What am i doing wrong? #define TEScrpLength 0xab0 #define TEScrpHandle 0xab4 short scrap_count; main () { ... init_the_scrap (); ... } init_the_scrap (){ ScrapStuff *scrap_stuff; scrap_stuff = InfoScrap (); scrap_count = ! ( scrap_stuff->scrapCount ); /* get_scrap (); Dosn't work yet */ } do_command (help) int help;{ ... case TECOPY: TECopy (h_text); put_scrap (); break; case TEPASTE: /* get_scrap (); Dosn't work yet */ TEPaste (h_text); break; ... } /* This is working !!!!!! */ put_scrap (){ Handle text_scrap; ScrapStuff *scrap_stuff; ZeroScrap (); text_scrap = (Ptr) TEScrpHandle; text_scrap = (Ptr) *text_scrap; HLock (text_scrap); PutScrap (GetHandleSize (text_scrap), "TEXT", *text_scrap); HUnlock (text_scrap); scrap_stuff = InfoScrap (); scrap_count = scrap_stuff->scrapCount; } /* Dosn't work yet -------------------------------------------------------- get_scrap (){ Handle hdl, text_scrap; int text_length, off, *text_length_ptr; ScrapStuff *scrap_stuff; scrap_stuff = InfoScrap (); if (scrap_count == scrap_stuff->scrapCount) return; scrap_count = scrap_stuff->scrapCount; hdl = NewHandle (0); text_length = GetScrap (hdl, "TEXT", &off); if (text_length > 0){ text_scrap = (Ptr) TEScrpHandle; text_scrap = (Ptr) *text_scrap; SetHandleSize (text_scrap, text_length); text_length_ptr = (Ptr) TEScrpLength; *text_length_ptr = text_length; HLock (hdl); HLock (text_scrap); BlockMove (*hdl, *text_scrap, text_length); HUnlock (hdl); HUnlock (text_scrap); } DisposHandle (hdl); } */ ============================================================================== ============================================================================== QUESTION 3. The program shall only display files that contains FONT resources when calling SFGetFile. How should i make a filter that takes away the other? I have tried but i think it was some problems with Pascal and C calling conventions. ============================================================================== Once again Many Thanks in Advance from ... ... Roland Karlsson.