Skip to content

Commit

Permalink
Merge 8.6
Browse files Browse the repository at this point in the history
  • Loading branch information
jan.nijtmans committed Nov 15, 2023
2 parents 8a1ad98 + 5b7abe2 commit ebac6ea
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 23 deletions.
4 changes: 2 additions & 2 deletions library/print.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ namespace eval ::tk::print {
return $tmpfile
}
}

if {[tk windowingsystem] eq "win32"} {
variable printer_name
variable copies
Expand Down Expand Up @@ -969,7 +969,7 @@ proc ::tk::print {w} {
::tk::print::_printcanvas $w
set printfile /tmp/tk_canvas.pdf
::tk::print::_print $printfile
}
}
"Text,win32" {
tailcall ::tk::print::_print_data [$w get 1.0 end] 1 {Arial 12}
}
Expand Down
6 changes: 3 additions & 3 deletions macosx/tkMacOSXImage.c
Original file line number Diff line number Diff line change
Expand Up @@ -679,7 +679,7 @@ CreateCGImageFromDrawableRect(
* Extract PDF data from a MacOSX drawable.
*
* Results:
* Returns a CFDataRef that can be written to a file.
* Returns a CFDataRef that can be written to a file.
*
* NOTE: The x,y coordinates should be relative to a coordinate system
* with origin at the bottom left as used by NSView, not top left
Expand All @@ -706,9 +706,9 @@ CreatePDFFromDrawableRect(
return NULL;
}
NSRect bounds, viewSrcRect;

/*
* Get the child window area in NSView coordinates
* Get the child window area in NSView coordinates
* (origin at bottom left).
*/

Expand Down
6 changes: 3 additions & 3 deletions macosx/tkMacOSXPrint.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ CFStringRef urlFile = NULL;
int StartPrint(void *clientData, Tcl_Interp * interp,
int objc, Tcl_Obj * const objv[]);
OSStatus FinishPrint(NSString *file, int buttonValue);
int MakePDF(void *clientData, Tcl_Interp *ip,
int MakePDF(void *clientData, Tcl_Interp *ip,
int objc, Tcl_Obj *const objv[]);
int MacPrint_Init(Tcl_Interp * interp);

Expand Down Expand Up @@ -362,7 +362,7 @@ int MakePDF
}

/*Get window and render to PDF.*/

path = Tk_NameToWindow(ip, Tcl_GetString(objv[1]), Tk_MainWindow(ip));
if (path == NULL) {
return TCL_ERROR;
Expand All @@ -375,7 +375,7 @@ int MakePDF
height = Tk_Height(path);

pdfData = CreatePDFFromDrawableRect(d, 0, 0, width, height);

NSData *viewData = (NSData*)pdfData;
[viewData writeToFile:@"/tmp/tk_canvas.pdf" atomically:YES];
return TCL_OK;
Expand Down
7 changes: 4 additions & 3 deletions tests/font.test
Original file line number Diff line number Diff line change
Expand Up @@ -2339,14 +2339,15 @@ test font-43.1 {FieldSpecified procedure: specified vs. non-specified} -body {
} -result [font actual {times 0} -family]


test font-44.1 {TkFontGetPixels: size < 0} -constraints failsOnUbuntu -setup {
test font-44.1 {TkFontGetPixels: size < 0} -setup {
set oldscale [tk scaling]
} -body {
set oldsize [expr {-(-12.0 / $oldscale)}]
tk scaling 0.5
font actual {times -12} -size
expr {round([font actual {times -12} -size] / $oldscale * 0.5) - round($oldsize) == 0}
} -cleanup {
tk scaling $oldscale
} -result 24
} -result 1
test font-44.2 {TkFontGetPoints: size >= 0} -constraints {noExceed haveTimes12Font} -setup {
set oldscale [tk scaling]
} -body {
Expand Down
4 changes: 2 additions & 2 deletions tests/menu.test
Original file line number Diff line number Diff line change
Expand Up @@ -4284,7 +4284,7 @@ test menu-40.1 {Use-after-free if menu destroyed while posted - bug 09a11fb1228f
} -constraints {pressbutton} -body {
set done false
event generate {} <Motion> -x 100 -y 100
toplevel .t
toplevel .t
menu .t.m
.t.m add command -command {puts Marco} -label Marco
.t.m add command -command {puts Polo} -label Polo
Expand All @@ -4299,7 +4299,7 @@ test menu-40.2 {Use-after-free if menu destroyed while posted - bug 09a11fb1228f
} -constraints {movemouse} -body {
set done false
event generate {} <Motion> -x 100 -y 100
toplevel .t
toplevel .t
menu .t.m
.t.m add command -command {puts Marco} -label Marco
.t.m add command -command {puts Polo} -label Polo
Expand Down
2 changes: 1 addition & 1 deletion unix/Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -1402,7 +1402,7 @@ tkMacOSXFont.o: $(MAC_OSX_DIR)/tkMacOSXFont.c
tkMacOSXHLEvents.o: $(MAC_OSX_DIR)/tkMacOSXHLEvents.c
$(CC) -c $(CC_SWITCHES) $(MAC_OSX_DIR)/tkMacOSXHLEvents.c

tkMacOSXImage.o: $(MAC_OSX_DIR)/tkMacOSXImage.c
tkMacOSXImage.o: $(MAC_OSX_DIR)/tkMacOSXImage.c
$(CC) -c $(CC_SWITCHES) $(MAC_OSX_DIR)/tkMacOSXImage.c

tkMacOSXInit.o: $(MAC_OSX_DIR)/tkMacOSXInit.c tkConfig.sh
Expand Down
19 changes: 10 additions & 9 deletions unix/tkUnixRFont.c
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@ GetFont(

static void
GetTkFontAttributes(
Tk_Window tkwin,
XftFont *ftFont,
TkFontAttributes *faPtr)
{
Expand All @@ -194,12 +195,12 @@ GetTkFontAttributes(
double size, ptsize;

(void) XftPatternGetString(ftFont->pattern, XFT_FAMILY, 0, familyPtr);
if (XftPatternGetDouble(ftFont->pattern, XFT_SIZE, 0,
&ptsize) == XftResultMatch) {
size = ptsize;
} else if (XftPatternGetDouble(ftFont->pattern, XFT_PIXEL_SIZE, 0,
if (XftPatternGetDouble(ftFont->pattern, XFT_PIXEL_SIZE, 0,
&ptsize) == XftResultMatch) {
size = -ptsize;
} else if (XftPatternGetDouble(ftFont->pattern, XFT_SIZE, 0,
&ptsize) == XftResultMatch) {
size = ptsize;
} else if (XftPatternGetInteger(ftFont->pattern, XFT_PIXEL_SIZE, 0,
&pxsize) == XftResultMatch) {
size = (double)-pxsize;
Expand All @@ -221,7 +222,7 @@ GetTkFontAttributes(
#endif /* DEBUG_FONTSEL */

faPtr->family = Tk_GetUid(family);
faPtr->size = size;
faPtr->size = TkFontGetPoints(tkwin, size);
faPtr->weight = (weight > XFT_WEIGHT_MEDIUM) ? TK_FW_BOLD : TK_FW_NORMAL;
faPtr->slant = (slant > XFT_SLANT_ROMAN) ? TK_FS_ITALIC : TK_FS_ROMAN;
faPtr->underline = 0;
Expand Down Expand Up @@ -357,7 +358,7 @@ InitFont(
return NULL;
}
fontPtr->font.fid = XLoadFont(Tk_Display(tkwin), "fixed");
GetTkFontAttributes(ftFont, &fontPtr->font.fa);
GetTkFontAttributes(tkwin, ftFont, &fontPtr->font.fa);
GetTkFontMetrics(ftFont, &fontPtr->font.fm);
Tk_DeleteErrorHandler(handler);
if (errorFlag) {
Expand Down Expand Up @@ -513,7 +514,7 @@ TkpGetFontFromAttributes(
if (faPtr->size > 0.0) {
XftPatternAddDouble(pattern, XFT_SIZE, faPtr->size);
} else if (faPtr->size < 0.0) {
XftPatternAddDouble(pattern, XFT_SIZE, TkFontGetPoints(tkwin, faPtr->size));
XftPatternAddDouble(pattern, XFT_PIXEL_SIZE, -faPtr->size);
} else {
XftPatternAddDouble(pattern, XFT_SIZE, 12.0);
}
Expand Down Expand Up @@ -682,7 +683,7 @@ TkpGetSubFonts(

void
TkpGetFontAttrsForChar(
TCL_UNUSED(Tk_Window), /* Window on the font's display */
Tk_Window tkwin, /* Window on the font's display */
Tk_Font tkfont, /* Font to query */
int c, /* Character of interest */
TkFontAttributes *faPtr) /* Output: Font attributes */
Expand All @@ -694,7 +695,7 @@ TkpGetFontAttrsForChar(
XftFont *ftFont = GetFont(fontPtr, ucs4, 0.0);
/* Actual font used to render the character */

GetTkFontAttributes(ftFont, faPtr);
GetTkFontAttributes(tkwin, ftFont, faPtr);
faPtr->underline = fontPtr->font.fa.underline;
faPtr->overstrike = fontPtr->font.fa.overstrike;
}
Expand Down

0 comments on commit ebac6ea

Please sign in to comment.